/serverless-infrastructure

BSD 2-Clause "Simplified" LicenseBSD-2-Clause

Infrastructure

This repo contains the infrastructure code for a shared infrastructure. It uses Serverless Framework to deploy infrastructure.

Organization

This repository is structure by resource type instead of end-to-end configuration. This makes the code easier to write but has the drawback of not having any ordering or relationships defined in code between resources. This means you have to know about resource relationships on your own without relying on CloudFormation finding errors during initial validation. Because not a lot of reconfiguration is expected, this should be fine.

To deploy resources, change into the appropriate subdirectory and run:

serverless deploy

Stages

Stages are represented by different AWS organization accounts. Where different configuration is needed between accounts, resources should be isolated in a file names after the stage/account. The serverless.yml should then have the following:

provider:
  name: aws
  stage: ${opt:stage, env:SLS_STAGE, 'dev'}
  profile: ${opt:aws-profile, env:AWS_PROFILE, env:AWS_DEFAULT_PROFILE, 'default'}
  
resources: ${file(./${self:provider.stage}.yml)}

Choosing Serverless Framework

While Serverless Framework is aimed at being a system and function deployment tool, it compiles down into CloudFormation that is deployed. The decision was made to not introduce another tool for simplicity's sake and because solving issues with the DSL of Serverless Framework would potentially be re-applicable to other systems.