Split CloudFormation Stacks

Placing all your resources into a single stack is going to create pain for you later on. Moving and renaming resources between stacks can be quite tricky. Once a resource is managed by a CloudFormation stack it’s not possible to remove that resource without deleting it, and it’s not possible to move a resource from one stack to another. Splitting up your resources across multiple stacks can really help. Here are some suggestions on how you can achieve that.

Continue reading “Split CloudFormation Stacks”

Safe Deployments with API Gateway and Lambda AutoPublishAlias

Take advantage of the automatic versioning and aliasing of your Lambdas to instantly shift traffic to your new API deployments. Rollback by repointing the problematic Lambda’s alias to the previous version.

TL;DR

  1. Use the Serverless Application Model (SAM) AutoPublishAlias parameter to have CloudFormation automatically version and alias your Lambdas upon deployment
  2. Reference your Lambda Alias from your OpenAPI definition
  3. Deploy
Continue reading “Safe Deployments with API Gateway and Lambda AutoPublishAlias”

How to use OpenAPI with API Gateway

Use an OpenAPI specification to define API Gateway APIs. This is good practice because:

  1. The specification forces you to think about the design upfront before touching code which is expensive to correct later
  2. This contract first approach allows frontend, backend, and test developers to work in parallel
  3. Endpoints can be mocked for developers to test against
  4. Serverless Application Model (SAM) uses the specification to configure the API Gateway API, this makes it living documentation, evolving alongside code and infrastructure.
Continue reading “How to use OpenAPI with API Gateway”