MS Boilerplate is a boilerplate to create micro-services with a basic initial structure.
This project uses sam to build the infrastructure on AWS that includes lambda and a gateway api using an openapi
Table of contents
Dependencies | Description |
---|---|
Javascript Runtime | |
AWS SAM CLI | |
Virtualization containers | |
Terraform | |
Wrapper for Terraform |
- To clone repository you need to have git installed:
git clone git@github.com:GrooveCommunity/ms-boilerplate.git
- Enter repository
cd ms-boilerplate
- To install dependencies you need to have NodeJS installed:
npm install
- Copy file
env.json.example
toenv.json
and modify it accordingly
This steps deploy at chosen environment infrastructure and generates env to deploy this microservice of your machine.
- Declare environments variables:
AWS_ACCOUNT_ID=<profile name>
JWT_SECRET=<JWT secret to authorize requests>
ENV_NAME=<environment short name, like "dev" or "prd">
- To run terragrunt you need terragrunt installed:
terragrunt apply --terragrunt-working-dir iac
To learn more Terragrunt.
When finished with ✔️ sucess it will show this:
Apply complete! Resources: 5 added, 0 changed, 0 destroyed.
And it should have created a file called sam-params
.
This step will deploy your local code to AWS.
⚠️ Atention: To run the deploy you need to have performed the above steps.
- Build all files to single file JS peer function:
npm run build
- Run the following (the S3 bucket should already exist):
sam deploy --stack-name boirleplate-$ENV_NAME --s3-bucket $AWS_ACCOUNT_ID-boilerplate-$ENV_NAME-sam-stack --parameter-overrides "$(cat sam-params)" --capabilities "CAPABILITY_NAMED_IAM" -t template.yaml
To run this microservice and dependencies locally you need aws sam cli installed.
- Start build on watch mode with typescript and ./prepare.js to install only prod dependencies at dist:
npm run start
- Start api with AWS SAM CLI:
sam local start-api --env-vars env.json
To learn more AWS SAM CLI.
This project exists thanks to all these people.