Boilerplate Golang API with AWS Severless Application Model (SAM) Deployment to AWS Lambda & API Gateway
$ make bundle-lambda
packaged-template.yaml
)
$ aws s3 mb s3://my-bucket
$ aws cloudformation package \
--template-file template.yaml \
--s3-bucket my-bucket \
--output-template-file packaged-template.yaml
$ aws cloudformation deploy \
--template-file packaged-template.yaml \
--stack-name go-serverless-api-stack \
--capabilities CAPABILITY_IAM
AWS API Gateway addresses take the following format.
https://<api-rest-id>.execute-api.<your-aws-region>.amazonaws.com/<api-stage>
$ aws apigateway get-rest-apis
{
"items": [
{
"id": "0qu18x8pyd",
"name": "go-serverless-api-stack",
"createdDate": 1523987269,
"version": "1.0",
"apiKeySource": "HEADER",
"endpointConfiguration": {
"types": [
"EDGE"
]
}
}
]
}
$ curl -s https://0qu18x8pyd.execute-api.eu-west-1.amazonaws.com/Stage/healthz
ok
$ curl -s https://0qu18x8pyd.execute-api.eu-west-1.amazonaws.com/Prod/healthz
ok
$ aws cloudformation delete-stack \
--stack-name go-serverless-api-stack
$ make run
$ make test-run
$ go test ./...