This repository provides an example of using the serverless framework with split stacks i.e. splitting the CloudFormation resources across multiple stacks.
CloudFormation Resouce max limit is 200, So if we add more microservice then we will see below error message. In this case we have to slipt our stack
Error --------------------------------------------------
The CloudFormation template is invalid: Template format error: Number of resources, 201, is greater than maximum allowed, 200
- ApiGateway Configuration
- Create S3 Bucket
- Login and Registration
- Custom authentication
- MongoDB Database
- Upload Image in S3 Bucket
/serverless.yml
- the base stack Contains API Gateway, API Authorizer, Create S3 Bucket 4XX & 5XX GatewayResponse/api/login/serverless.yml
- the stack for user registration login/api/admin/serverless.yml
- the stack for posts management/api/common/serverless.yml
- the stack for upload file in s3 bucket base64 string and multipart
You will need:
- nodejs 14 or higher
- an AWS account
- the awscli tool
- serverless CLI tool (either installed globally i.e.
npm install -g serverless
or locally)
Steps:
- First change the configuration in
config-(stage name).yml
- Install the npm modules
npm install
- Deploy the base stack
`serverless deploy --stage dev`
if you have multiple AWS profile then use below comments
`serverless deploy --aws-profile my_profile_name --stage dev`
- Change into the subdirectories and deploy the other stacks (using the same stage name):
cd api/admin
serverless deploy --stage dev
cd api/login
serverless deploy --stage dev
cd api/common
serverless deploy --stage dev