Skip to main content

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.

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 run cdk deploy manually — after that the pipeline is self-managing and updates itself whenever you push changes to your configured GitHub branch.

Deploy Workflow

1

Build the project

Compile the TypeScript source files to JavaScript. CDK reads the compiled .js files at runtime, so this step must be run before synthesis or deployment.
npm run build
This invokes 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.
2

Synthesize CloudFormation templates

Generate the CloudFormation templates from your CDK code. The output is written to the cdk.out/ directory.
cdk synth
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.
3

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.
cdk diff
The diff output shows resources that will be added, modified, or removed. Review it carefully — IAM permission changes are highlighted separately.
4

Deploy the pipeline stack

Push the AwsCdkPipelineStack to your AWS account. This is the one-time manual deployment that creates the pipeline and all supporting infrastructure.
cdk deploy AwsCdkPipelineStack
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.
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.
5

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:
  1. Source — pulls the latest commit from your GitHub branch
  2. Build — runs npm ci, npm run build, and npx cdk synth in CodeBuild
  3. UpdatePipeline — the self-mutation stage; updates the pipeline definition itself if it changed
  4. Any application stages you have added
If the GitHub connection has not been authorized yet, the Source stage will show a Pending status. Go to Developer Tools → Connections in the console and approve the connection.
The bin/aws-cdk-pipeline.ts file currently hardcodes account 602143770054 and region ap-south-1. If you deploy without updating these values, the stack will be created in that account and region. Make sure you have replaced them with your own values as described in Configuration before running cdk deploy.

What Gets Created

The initial cdk deploy provisions the following AWS resources:
ResourceDetails
AWS CodePipelineNamed TestPipeline; orchestrates source, build, self-mutation, and application stages
Amazon S3 bucketStores pipeline artifacts (source archives, synth output) encrypted with SSE-S3
AWS CodeBuild projectRuns the synth shell step (npm ci, npm run build, npx cdk synth)
IAM rolesPipeline execution role, CodeBuild service role, and CloudFormation deployment role
CodeStar ConnectionGitHub integration (must be manually authorized in the console on first use)
All resources are defined and managed by the CDK stack, so they can be updated or removed via CDK as the application evolves.

Self-Mutation

One of the key features of the CDK Pipelines library is self-mutation. After the first manual deploy:
  1. You push a commit to the configured GitHub branch (aws-pipeline by default).
  2. The pipeline’s Source stage detects the change and pulls the new code.
  3. The Build stage synthesizes the updated CloudFormation templates.
  4. The UpdatePipeline stage compares the new pipeline definition against the currently deployed one and applies any structural changes — adding stages, modifying build commands, etc.
  5. The pipeline then re-runs from the beginning with the updated definition.
This means you never need to run 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 the aws-cdk-pipeline/ directory:
CommandDescription
npm run buildCompile TypeScript to JavaScript via tsc
npm run watchWatch for file changes and recompile automatically via tsc -w
npm run testRun the Jest unit test suite
npm run cdkInvoke the CDK CLI via the locally installed cdk binary
cdk deployDeploy the stack (or a named stack) to your AWS account
cdk diffCompare the synthesized stack with the currently deployed state
cdk synthEmit the CloudFormation template(s) to cdk.out/

Build docs developers (and LLMs) love