Every push to theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/okruti-raghuraj/aws-1/llms.txt
Use this file to discover all available pages before exploring further.
aws-pipeline branch of the RaghurajSingh/SMS GitHub repository kicks off a fully automated chain: CodePipeline pulls the source, a CodeBuild project synthesizes CloudFormation templates, the pipeline updates its own definition if needed, and then each application stage is deployed in sequence. The entire flow is defined as TypeScript code and lives alongside the application it ships.
Pipeline Stages
1. Source
The pipeline watches a specific GitHub repository and branch. When a commit lands, CodePipeline automatically starts a new execution:- Repository:
RaghurajSingh/SMS - Branch:
aws-pipeline - Trigger: Any push to the branch (CodeStar Connections webhook)
2. Synth
The Synth step is aShellStep that runs inside a managed CodeBuild environment. It installs dependencies, compiles TypeScript, and synthesizes the CloudFormation templates:
cdk.out/ cloud assembly — a directory of CloudFormation templates and assets that fully describes every stack in the app.
3. Self-Mutation
After synthesis, CDK Pipelines compares the newly produced pipeline definition against the currently deployed CodePipeline. If the pipeline structure has changed (new stages, updated build commands, different source branch), the pipeline updates itself before proceeding. This update step runs as a separate CodePipeline action.Self-mutation means you never need to run
cdk deploy again after the first bootstrap. Any change to the pipeline definition — adding a deployment stage, changing environment variables, updating the synth commands — is automatically applied on the next push, because the pipeline redeploys itself before it deploys your application.4. Deploy
Once the pipeline is up to date, it deploys eachcdk.Stage that was added via pipeline.addStage(...). Stages run in the order they were added and can contain one or more CloudFormation stacks.
Pipeline Stack Code
The entire pipeline is defined in a single CDK stack:bin/aws-cdk-pipeline.ts with an explicit AWS account and region:
env is required for CDK Pipelines — environment-agnostic stacks cannot be used because the pipeline must know where to deploy.
crossAccountKeys: false
By default, CDK Pipelines creates a customer-managed KMS key to encrypt the CodePipeline artifact bucket. Setting crossAccountKeys: false disables this and uses SSE-S3 (AWS-managed encryption) instead.
crossAccountKeys: true (default)
Creates a KMS Customer Managed Key. Required when the pipeline deploys to a different AWS account. Adds ~$1/month per key in KMS charges.
crossAccountKeys: false
Uses SSE-S3 (AES-256) for the artifact bucket. No KMS cost. Sufficient when all pipeline stages deploy into the same account. Used in this project.
Self-Mutation Explained
The self-mutation step is what makes CDK Pipelines fundamentally different from a hand-rolled CodePipeline. When the pipeline runs, it executes acdk deploy of its own pipeline stack using the freshly synthesized cloud assembly. Only after the pipeline stack is confirmed up to date does execution continue to the application deployment stages.
Once the pipeline is bootstrapped with a single
cdk deploy, you never need to run cdk deploy locally again. The pipeline becomes the sole mechanism for infrastructure changes — your git history is your deployment history.Adding Application Stages
Application workloads are added to the pipeline using thecdk.Stage pattern. A Stage groups one or more cdk.Stack instances that represent a logical deployment environment (for example, staging or production).
The project already includes the scaffolding for a Lambda deployment stage, currently commented out in both source files. The code below reflects the actual file contents — every line is commented out and nothing is active yet:
AwsCdkPipelineStack:
Deployment Flows
Bootstrap (first time only)
Prepare your AWS account and region for CDK deployments. This creates the CDK bootstrap stack (S3 bucket, ECR repository, IAM roles) that CodePipeline will use.
Authenticate with GitHub
Create an AWS CodeStar Connection to GitHub in the
ap-south-1 region and approve it in the AWS Console. CDK Pipelines uses this connection as the webhook source trigger.Deploy the pipeline stack once
Run
cdk deploy from your local machine exactly once to create the CodePipeline pipeline in AWS.Push to trigger the pipeline
From this point on, every push to the
aws-pipeline branch triggers the pipeline automatically. No further local cdk deploy commands are needed.