
The diagram source is the draw.io file at
images/software/developer/estate/infra/sg-infra/architecture.drawio. To change the diagram, edit that source in draw.io, re-export it as PNG to architecture.png in the same folder, and commit both.Overview
SG-Infra is a single TypeScript AWS CDK application. Like the legacy repo it does not deploy resources directly: it defines a self-mutating CodePipeline that deploys everything. Unlike the legacy repo it is written in TypeScript (the team standard), is sourced from GitHub, and splits the infrastructure into four separate stacks so that concerns, and especially the data volume, are isolated from each other.High-Level Structure
- The CDK app (
bin/cdk_build.ts) contains the pipeline stack (SgInfraPipelineStack). - The pipeline stack defines the self-mutating CodePipeline (
SgInfraPipeline) and points it at the GitHub repository. - The pipeline runs one stage, named
prod, which deploys four stacks:SgInfraSecurityStack,SgInfraBackupStack,SgInfraVolumeStackandSgInfraMongoInstanceStack. - Every stack is tagged with
ProjectFMP.
The CI/CD Pipeline
- Source: the
prodbranch of the GitHub repository, connected through an AWS CodeConnections connection. This is the modern, GitHub based approach, and a key difference from the legacy repo, which is sourced from CodeCommit. - Synth step: changes into the
CdkBuilddirectory, runsnpm install, thennpx cdk synth. - Self-mutation is enabled, so the pipeline updates itself before deploying the stacks.
- Assets are published one at a time rather than in parallel.
- A dedicated S3 artifact bucket (
sg-infra-pipeline-artifacts) holds pipeline artifacts.
The Four Stacks and Why They Are Separated
The singleprod stage deploys four stacks. Splitting them is deliberate, and is one of the main improvements over the legacy single grouping:
SgInfraSecurityStacklooks up the shared VPC, and creates the security groups, the EC2 key pair, the MongoDB connection secret, and the SSM configuration that consumers read.SgInfraBackupStackcreates the versioned S3 backup bucket.SgInfraVolumeStackcreates the persistent EBS data volume. Keeping the volume in its own stack means the database storage has an independent lifecycle and is not torn down when the instance is replaced.SgInfraMongoInstanceStackcreates the EC2 instance, attaches the data volume, and provisions MongoDB. It receives the VPC, security group, key pair, secret, data volume and backup bucket from the other stacks.
How a Change Reaches Production
1
Merge to prod
A change is merged to the
prod branch on GitHub.2
Pipeline triggers
The CodeConnections connection triggers the
SgInfraPipeline pipeline.3
Synth
The Synth step installs dependencies and runs
cdk synth.4
Self-mutate
The pipeline self-mutates, applying any change to the pipeline itself.
5
Deploy
The
prod stage deploys the four stacks in dependency order.Why It Is Built This Way
- TypeScript CDK and GitHub source bring SG-Infra onto the team standard tooling, which is the main reason it exists as the go-forward pattern.
- Separate stacks isolate the blast radius within the system. The volume in particular is isolated so that rebuilding or replacing the instance does not put the data at risk.
- The pattern is still a single account, single region, single environment deployment. As with the legacy repo, dev and production are separate databases on the one instance rather than separate environments. For now those are just
FMP_DEVandFMP_PROD, since only Fleet Management Platform uses SG-Infra so far; as more systems adopt it the instance will host many databases.
