AWS CDK (Cloud Development Kit) brings the full power of a programming language to infrastructure provisioning. Instead of writing raw CloudFormation YAML, you write TypeScript classes and functions that compile down to CloudFormation templates. CDK Pipelines, a higher-level construct built on top of CDK, takes that one step further by letting the pipeline manage and update itself every time you push a change.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.
What is the AWS CDK?
The AWS CDK is an open-source framework that lets you model AWS infrastructure as code using familiar programming languages — TypeScript, Python, Java, Go, and more. You write constructs (classes) that represent AWS resources; when you runcdk synth, the CDK synthesizes those constructs into a CloudFormation template that AWS can deploy.
This project uses aws-cdk-lib 2.20.0, the CDK v2 monolithic library that ships every AWS service construct in a single package. CDK v2 replaces the per-service packages of CDK v1 (e.g. the legacy @aws-cdk/core and @aws-cdk/aws-lambda packages visible in package.json are CDK v1 remnants no longer needed).
What is CDK Pipelines?
CDK Pipelines is a high-level construct library shipped as part ofaws-cdk-lib/pipelines. It wraps AWS CodePipeline to give you a self-mutating pipeline — a pipeline that can update its own infrastructure definition on every push without any manual cdk deploy step.
The self-mutation loop works like this:
- Push — a developer pushes a commit to the watched GitHub branch.
- Source — CodePipeline detects the change and pulls the new source.
- Synth — the pipeline runs
cdk synthto produce fresh CloudFormation templates. - Self-mutation — CDK Pipelines compares the newly synthesized pipeline definition against the currently deployed one. If they differ, it updates the pipeline itself first.
- Deploy — once the pipeline is up to date, it deploys all application stages in order.
Key Constructs
| Construct | Module | Purpose |
|---|---|---|
CodePipeline | aws-cdk-lib/pipelines | Top-level construct that creates and manages the CodePipeline pipeline, including the self-mutation stage |
CodePipelineSource | aws-cdk-lib/pipelines | Static factory for pipeline source actions — GitHub, CodeCommit, S3, ECR, etc. |
ShellStep | aws-cdk-lib/pipelines | Runs arbitrary shell commands inside a CodeBuild project; used here for the Synth step |
cdk.Stack | aws-cdk-lib | A unit of deployment — maps 1:1 to a CloudFormation stack; all resources are defined inside a Stack |
cdk.Stage | aws-cdk-lib | A group of one or more stacks that are deployed together as a logical application environment (e.g. staging, production) |
cdk.App | aws-cdk-lib | The root of the CDK construct tree; app.synth() triggers synthesis of all stacks |
CDK Context Flags
Thecdk.json file at the project root configures the CDK CLI and sets feature flags via the context object. Feature flags let the CDK team ship safer defaults for new projects without breaking existing ones.
true flag opts the project into a recommended behaviour change. Some notable ones:
@aws-cdk/aws-iam:minimizePolicies— consolidates IAM policy statements where possible, keeping generated policies lean.@aws-cdk/aws-lambda:recognizeVersionProps— ensures Lambda version hashes change when configuration properties change, so new versions are published correctly.@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021— enforces TLS 1.2 (2021) as the minimum security policy on new CloudFront distributions.@aws-cdk/core:target-partitions— limits synthesized ARNs to theawsandaws-cnpartitions, preventing accidental deployment to GovCloud unless explicitly requested.
app field tells the CDK CLI how to execute the entry point. Here it uses ts-node --prefer-ts-exts so TypeScript source is run directly without a prior compile step during cdk synth and cdk deploy.
TypeScript Compilation
The project uses the TypeScript compiler (tsc) configured by tsconfig.json. The compiler targets ES2018 ("target": "ES2018") and emits CommonJS modules ("module": "commonjs"), which is the standard setup for Node.js-based CDK applications. Three workflows are available:
cdk.json — npx ts-node --prefer-ts-exts bin/aws-cdk-pipeline.ts — which bypasses the compiled .js files entirely and runs TypeScript source directly. This is the standard CDK v2 setup.