This guide walks you through everything needed to deploy a self-mutating CI/CD pipeline to your AWS account using the AWS CDK Pipeline project. By the end you will have a running AWS CodePipeline that watches a GitHub repository and automatically updates itself whenever you push changes to your CDK infrastructure code.Documentation 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.
Install prerequisites
Make sure the following tools are installed and available on your Verify everything is in place:
PATH before continuing:- Node.js 14 or later — nodejs.org
- AWS CLI v2 — AWS CLI installation guide
- AWS CDK CLI — install the same version used by this project globally with npm:
Install dependencies
Install all Node.js dependencies declared in The key runtime dependencies that will be installed are:
package.json:Configure GitHub source
Open The original source points to
lib/aws-cdk-pipeline-stack.ts and update the CodePipelineSource.gitHub() call to point at your own GitHub repository and branch:CodePipelineSource.gitHub('RaghurajSingh/SMS', 'aws-pipeline'). Change both the repository (owner/repo) and the branch name to match your setup.CDK Pipelines uses a GitHub connection managed by AWS CodeStar Connections under the hood. The first time you deploy, AWS will prompt you to authorise the connection in the AWS console.Set your AWS environment
Open Alternatively, use environment variables so the file does not contain a hardcoded account ID:
bin/aws-cdk-pipeline.ts and replace the hardcoded account and region with your own values:Bootstrap CDK
CDK bootstrapping provisions the S3 bucket, ECR repository, and IAM roles that CDK needs to deploy stacks into your account and region. Run this once per account/region combination:For example:
What happens after deploy
Oncecdk deploy completes, AWS CodePipeline takes over:
- Pipeline is created in the CodePipeline console under the name
TestPipeline. - First execution starts immediately — it clones your GitHub repository, runs the synth step (
npm ci,npm run build,npx cdk synth), and self-mutates the pipeline stack if needed. - Every subsequent push to your configured branch triggers a new pipeline execution, which again self-mutates before deploying any application stages you have added.
Available npm scripts
The following scripts are defined inpackage.json for day-to-day development: