Skip to content

gabrielbenicio/ms-boilerplate

 
 

Repository files navigation

MS Boilerplate

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

🔍 Requirements

Dependencies Description
node-version Javascript Runtime
sam-version AWS SAM CLI
docker-version Virtualization containers
terraform-version Terraform
terragrunt-version Wrapper for Terraform

🔨 Project setup

  1. To clone repository you need to have git installed:
git clone git@github.com:GrooveCommunity/ms-boilerplate.git
  1. Enter repository
cd ms-boilerplate
  1. To install dependencies you need to have NodeJS installed:
npm install
  1. Copy file env.json.example to env.json and modify it accordingly

☁️ Provisioning the infrastructure

This steps deploy at chosen environment infrastructure and generates env to deploy this microservice of your machine.

  1. Declare environments variables:
AWS_ACCOUNT_ID=<profile name>

JWT_SECRET=<JWT secret to authorize requests>

ENV_NAME=<environment short name, like "dev" or "prd">
  1. 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.

⬆️ Deploying to AWS

This step will deploy your local code to AWS.

⚠️ Atention: To run the deploy you need to have performed the above steps.

  1. Build all files to single file JS peer function:
npm run build
  1. 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

▶️ Running locally

To run this microservice and dependencies locally you need aws sam cli installed.

  1. Start build on watch mode with typescript and ./prepare.js to install only prod dependencies at dist:
npm run start
  1. Start api with AWS SAM CLI:
sam local start-api --env-vars env.json

To learn more AWS SAM CLI.

💪 Dev Team

This project exists thanks to all these people.

MarcosMassa

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 55.5%
  • HCL 41.9%
  • JavaScript 2.6%