Boilerplate code of AWS Fargate service with Go deployed with AWS CDK.
Batteries included:
- Service logic stub in Go
- Using Go modules
- Using AWS services in container (S3)
- Granting permissions to call AWS services
- Multi-stage build
- Testing in build container
- Running locally as an app
- Running locally in Docker container
- Deployment as a AWS Fargate service
- Deployment to AWS using AWS CDK
Installation:
- Clone the repo
- Have Docker installed
- Install AWS CDK: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html
- Run
cd cdk; npm install
- Configure AWS profile using
aws configure
- Check the profile is setup using
aws s3 ls --profile default
(if you want to use another AWS profile - editAWS_PROFILE
variable inMakefile
) - Deploy the stack using
make deploy
- Enjoy!
- Undeploy the stack using
make destroy
Commands (see Makefile for details):
make run
- run locally as an appmake run_docker
- run locally in Docker containermake build
- build Linux executablemake build_docker
- build Docker containermake test
- run tests locallymake deploy
- deploys the stack to AWS (using default AWS profile)make destroy
- destroys the stack