With your tools installed and your configuration updated, you are ready to deploy the pipeline to AWS. The first deployment is the only time you need to runDocumentation 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.
cdk deploy manually — after that the pipeline is self-managing and updates itself whenever you push changes to your configured GitHub branch.
Deploy Workflow
Build the project
Compile the TypeScript source files to JavaScript. CDK reads the compiled This invokes
.js files at runtime, so this step must be run before synthesis or deployment.tsc using the project’s tsconfig.json. Any TypeScript errors will surface here. You can also use npm run watch during development to recompile automatically on file changes.Synthesize CloudFormation templates
Generate the CloudFormation templates from your CDK code. The output is written to the Review the synthesized template to confirm the pipeline, bucket, and IAM resources look as expected before deploying. This step also validates your CDK constructs without making any AWS API calls.
cdk.out/ directory.Preview changes
Compare the synthesized stack against what is currently deployed in your AWS account. On a first-time deploy there is nothing to compare against, but this is a useful habit to adopt before every subsequent change.The diff output shows resources that will be added, modified, or removed. Review it carefully — IAM permission changes are highlighted separately.
Deploy the pipeline stack
Push the CDK will display a summary of IAM changes and prompt for confirmation before proceeding. The deployment typically takes 2–5 minutes. When it completes, the pipeline resource exists in CodePipeline and will immediately start its first run.
AwsCdkPipelineStack to your AWS account. This is the one-time manual deployment that creates the pipeline and all supporting infrastructure.You only need to run
cdk deploy manually once. After this initial deployment the pipeline is self-mutating — pushing commits to your GitHub branch will trigger the pipeline to re-run and apply any CDK changes automatically. See Self-Mutation below.Verify in the AWS Console
Open the AWS CodePipeline console and select TestPipeline (or whatever name you configured). Watch the pipeline run through its stages:
- Source — pulls the latest commit from your GitHub branch
- Build — runs
npm ci,npm run build, andnpx cdk synthin CodeBuild - UpdatePipeline — the self-mutation stage; updates the pipeline definition itself if it changed
- Any application stages you have added
What Gets Created
The initialcdk deploy provisions the following AWS resources:
| Resource | Details |
|---|---|
| AWS CodePipeline | Named TestPipeline; orchestrates source, build, self-mutation, and application stages |
| Amazon S3 bucket | Stores pipeline artifacts (source archives, synth output) encrypted with SSE-S3 |
| AWS CodeBuild project | Runs the synth shell step (npm ci, npm run build, npx cdk synth) |
| IAM roles | Pipeline execution role, CodeBuild service role, and CloudFormation deployment role |
| CodeStar Connection | GitHub integration (must be manually authorized in the console on first use) |
Self-Mutation
One of the key features of the CDK Pipelines library is self-mutation. After the first manual deploy:- You push a commit to the configured GitHub branch (
aws-pipelineby default). - The pipeline’s Source stage detects the change and pulls the new code.
- The Build stage synthesizes the updated CloudFormation templates.
- The UpdatePipeline stage compares the new pipeline definition against the currently deployed one and applies any structural changes — adding stages, modifying build commands, etc.
- The pipeline then re-runs from the beginning with the updated definition.
cdk deploy again for pipeline infrastructure changes. Your Git history becomes the source of truth for the pipeline configuration.
CDK Commands Reference
The following commands are available from theaws-cdk-pipeline/ directory:
| Command | Description |
|---|---|
npm run build | Compile TypeScript to JavaScript via tsc |
npm run watch | Watch for file changes and recompile automatically via tsc -w |
npm run test | Run the Jest unit test suite |
npm run cdk | Invoke the CDK CLI via the locally installed cdk binary |
cdk deploy | Deploy the stack (or a named stack) to your AWS account |
cdk diff | Compare the synthesized stack with the currently deployed state |
cdk synth | Emit the CloudFormation template(s) to cdk.out/ |