To build and CloudForm this, you need:
- bash, git, curl
- AWS CLI 1.44.66+,
- local AWS API Key able to command CloudFormation and IAM Roles
- Docker 17.05+
- approx 900MBytes of free disk space
Actions:
- checkout the repo out locally
- run build_deploy_test.sh (example output here)
- open the Rest API URL reported by this script in your browser
- run teardown.sh
System diagram
The API is exposed via AWS API Gateway, which is integrated with Amazon Lambda Functions, which are reading/writing from/to DynamoDB table for persistence.
All of the below is references and relevant samples
References for used GoLang tooling
- AWS SDK -- Docs
- AWS SDK -- Sources
- Proper AWS CodeBuild template
- GoLang Programming Model for AWS Lambda
- This is what happens if you try to use alpine-based GoLang Docker to build your Lambdas
$ readelf -a main.built_in_alpine | grep Requesting
[Requesting program interpreter: /lib/ld-musl-x86_64.so.1]
$ readelf -a main.built_in_ubuntu | grep Requesting
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
Cloudforming API Gateway for Lambda
- Use proper Integration.Type
- More Docs on Integration
- Jayway's example - simplest yet still working, Stage also cloudfromed
- Lambda Versions
- tmaslen's example
- matsev's example
- zombie apocalypse example
- SO Example
- This is what happens if you shoot GET API requests as GET requests to Lambda Functions
Cloudforming DynamoDB
- Lambda-backed Rest-API sample <-- used that as starting point
CloudFormation
- Main Landing
- Intrinsic functions
- cfn_flip
- stelligent template collection
- Json to Yaml with CF Designer, but cfn_flip is much better
CI/CD maybes
- vamp
- GoCD
API Gateway <-> Amazon Lambda
- Dev Guide
- AWS Dev Guide, blueprints
- AWS Dev Guide, create event source
- Good AWS Sample with API dicsussion
- Cloud Guru sample relying on http client
- aws-lambda-go GH samples
Old, not needed for lambda, rewrite/transform magick
- Integration Pass-Through Behaviours
- Integration Request Parameters
- API Gateway Transforms Pictorial
- Same without pictures as a Developer Guide Book
- There's better integration for Lambda
- Cloudonaut example -- Swagger, Models, STAAHP
- More Swagger Madness
- Swagger at AwsLabs
- That is what happens if you use old style integration
- ...and more of the same
- That is what happens if you use old style integration and/or interpreted language
Talking to DynamoDB:
Testing against local DynamoDB mock
Local Testing for AWS services + SAM
AWS Security Model
- Service Assume Role with Perms for Resources
- IAM Policies
- Identity vs Resource policies
- Demystifying Resource-level perms (last section on auth tracing)
- The Diagram
- Access for Dynamo Table
Custom CloudWatch Metrics
Alternatives to Lambda
Sparta
- Sparta Code Pipeline + go dep
- Sparta - Behind the Shield, Apr 2016
- Go Framework for AWS Lambda
- Sparta - CodePipelines, Sept 2017
- GoFormation <-- not really what's needed, forces evaluation of intrinsics (completely mad and unuseable due to this)