Templates
Starting from an empty definition file means knowing which modules exist, which inputs each one takes, and which order they have to run in. A template is a working stack that already answers all three, so what you read here is a definition file you can copy from rather than assemble.
create-app writes a project with an app, an account and a region only. The stacks below are tested
against real infrastructure, so copy their modules into your octo.yaml and change the names.
What you get after that is the lifecycle.
aws-s3-website
The smallest one. No VPC, and it applies in seconds.
modules:
- moduleId: app-module
moduleClass: SimpleAppModule
moduleInputs:
name: aws-s3-website
- moduleId: account-module
moduleClass: AwsIniAccountModule
moduleInputs:
accountId: "${env.AWS_ACCOUNT_ID}"
app: "${{app-module.model.app}}"
- moduleId: region-module
moduleClass: AwsServerlessRegionModule
moduleInputs:
account: "${{account-module.model.account}}"
name: aws-s3-website
regionId: aws-us-east-1
- moduleId: s3-website-service-module
moduleClass: AwsS3StaticWebsiteServiceModule
moduleInputs:
bucketName: "${env.AWS_S3_WEBSITE_BUCKET_NAME}"
directoryPath: website
region: "${{region-module.model.region}}"
Four modules, and one of them produces the whole website: a bucket, its website configuration, a
public access block, a bucket policy, and one object per file in website/. The region before it
creates nothing; it says which AWS region the bucket goes in. Static
Website runs this one end to end, from scaffold to a URL you
can open.
aws-ecs-server
A container running on ECS behind an application load balancer, and the one worth reading even if you never deploy it, because it is composition at a realistic size. Eleven modules:
modules:
- moduleId: app-module # SimpleAppModule
- moduleId: account-module # AwsIniAccountModule
- moduleId: region-module # AwsMultiAzRegionModule, two AZs
- moduleId: backend-server-module # AwsServerModule
- moduleId: backend-deployment-v1-module # AwsDeploymentModule, an echo-server image
- moduleId: qa-environment-module # AwsEcsEnvironmentModule
- moduleId: public-subnet-module # AwsSimpleSubnetModule, with a NAT gateway
- moduleId: public-backup-subnet-module # AwsSimpleSubnetModule, in the second AZ
- moduleId: private-subnet-module # AwsSimpleSubnetModule, NAT-attached
- moduleId: backend-v1-qa-execution-module # AwsEcsExecutionModule
- moduleId: qa-api-alb-module # AwsEcsAlbServiceModule
Read it for the wiring rather than the resources. The private subnet is given the two public subnets
as siblings, one of them marked attachToNatGateway: true. The execution is given a deployment, an
environment, and a subnet, which is exactly what an execution is. The load balancer is given the two
public subnets and the execution it should route to. Every one of those is a node handed to a
module, not an ID copied between files.
This template creates a NAT gateway, which costs money by the hour. Tear it down when you are done.
aws-dynamodb-service
A DynamoDB table with a hash and range key, one global secondary index, one local secondary index, streams, and a TTL attribute. Four modules, and the interesting part is the comments in the generated definition file, which mark which of those can change on a live table and which recreate it.
More complete stacks
The Architectures pages build larger stacks end to end, such as an API on Lambda behind CloudFront, each with its whole definition file.
Your own
A stack is a definition file plus whatever it needs, so a starting point of your own is a directory somebody copies. That is fine, and for most teams it is the right amount of machinery.
The version that scales better is a module. A template says "here is a stack, change the names"; a module says "here is what a region means here, take it". If every project at your company begins by copying the same six modules and changing the same four inputs, those six modules are one module nobody has written yet. Create a Module covers writing it, and Publishing a Library covers handing it to other teams.