This repository contains the application templates.
This repo currently only contains a template for AWS SAM in golang.
- Execute from root projects folder
$ sam init
- Choose "Custom Template Location"
- Enter
https://github.com/scrambledeggs/kata
- Answer questions (has defaults)
- If choose 'n' on
with_own_db
,db_migration
is irrelevant
There are some not so straight forward steps to follow after installation:
- Update/create a .secrets.json
- Create and fill a AWS Secrets Manager for staging and production, staging/production-{{ cookiecutter.project_name }} respectively
- For some key values like
AuthorizerFunctionArn
,CertificateArnUs
, andCertificateArnAp
, you can get in AWS services or check other existing repo
- Deploy using github actions
- we need to deploy first to get
DistributionId
used by AWS Cloudfront for caching (see TODO for reason) - in step Deploy, you can check Cloudformation Outputs for the
CloudFrontDistributionId
- Update ENV / AWS Secret Manager
DistributionId
fromCloudFrontDistributionId
and redeploy
Register staging endpoints in core
- Go to
https://staging-{{ cookiecutter.project_name }}.booky.ph/endpoints
to validate your endpoints exist - Go to core/microservices
2.1. Create new microservice using
https://staging-{{ cookiecutter.project_name }}.booky.ph/endpoints
- Go to core/permissions 3.1. Create new permission name and description first 3.2. Edit newly created permission 3.3. Look for the list in Allowed Policies of the name you added in step 2.1
- Go to core/api-keys 4.1. Create new api key for new permission (even temporary) 4.2. Edit newly created api key 4.3 Search for permission name you created in step 3.1
Add api-key Add x-api-key in Header with value of api-key created in 4.1
Template has an API Gateway included that points to (test-/staging-)[project_name] upon deployment
Template has a basic setup of OpenAPI documentation
Template has a basic Makefile setup that I've tried executing while making the template
Execute this makefile command for local development
$ make dev
Execute this makefile command to deploy project
$ make deploy ENV=test
Template has a ready github actions that can deploy already, just adjust depending on your projects needs.
Template implements air for live-reloading, this works in the background
Execute this makefile command for local development with air live-reloading
$ make dev-watch
Template has options for migration handlers - goose or dbmate
Just install which is preferred to use.
Template also has an option for sqlc, and has a basic setup for it. Reads db/migrations
but can change file sqlc.yaml
for other configurations.
Template has a sample of basic handler HelloWorld under /functions/HelloWorldV1
accessible under /v1/hello-world
Template already has a ready endpoint for our Booky auth under AllEndpoints handler
Template has a sample of a cached endpoint that goes hand-in-hand with InvalidatedCachedWorldV1 under /functions/CachedWorldV1
accessible under /v1/cached-world
Use this sample endpoint to invalidate the cache of CachedWorldV1 under functions/InvalidatedCachedWorldV1
accessible under /v1/invalidate-cached-world
Creates an endpoint (BOOKY endpoint list) for /endpoints endpoint to read. Uses docs/api_contract.yaml
to generate list of endpoints
Reads from (env-)[project_name](by default) in AWS Secrets Manager and creates a file .secrets.json
Reads .secrets.json (by default) and creates a parameter-override string for sam deploy
or sam local start-api`
Since SAM can't have multiple template yet in one repo as of this writing, I opted to put this under root so it can work this way for now aws/aws-sam-cli#3555.
We welcome issue reports and pull requests to help improve these application templates.
- Find a way to add
!Ref CloudFrontDistribution
to get the ID created with CloudFrontDistribution and use it in Functions that would use to invalidate CloudFront caches in DISTRIBUTION_ID environment variable.
- Find a way to add it without circular dependency <- that's the error we get right now