# AWS Cloud Development Kit (AWS CDK)

Cloud service · AWS. Updated 2026-11-12. Page: https://blowstack.com/tools/cloud-services-hub/aws-cloud-development-kit-(aws-cdk)

> The AWS Cloud Development Kit (AWS CDK) is an open-source software development framework designed to model and provision cloud application resources using familiar programming languages.

Practice exams covering AWS Cloud Development Kit (AWS CDK): [ANS-C01 AWS Certified Advanced Networking - Specialty](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty), [SOA-C03 AWS Certified CloudOps Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate), [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 7 key features of AWS Cloud Development Kit (AWS CDK)

AWS CDK empowers developers to define cloud infrastructure in familiar programming languages, reuse components, seamlessly integrate with AWS services, manipulate resources directly, and enforces best practices automatically.

1. **Declarative Infrastructure as Code**: AWS CDK allows developers to define their cloud infrastructure using familiar programming languages such as TypeScript, Python, Java, and C#. This approach enables the use of conditionals, loops, and abstractions to create complex resources, making infrastructure management more efficient and less error-prone.
2. **Reusable Components**: Through the use of Constructs, the AWS CDK provides a way to encapsulate and reuse cloud components. Developers can bundle configurations into Constructs and share them within their organization or the broader community, promoting best practices and reducing duplication of effort.
3. **Integrated with AWS Services**: The AWS CDK comes with high-level components that pre-configure cloud resources with sane defaults, making it easier to integrate various AWS services such as Amazon EC2, Amazon S3, and Amazon DynamoDB into your applications with minimal manual configuration.
4. **Logical Resource Manipulation**: It enables direct interaction and manipulation of AWS CloudFormation resources, providing a fine-grained control over the cloud resources and facilitating complex deployments that can be difficult to achieve with CloudFormation alone.
5. **Built-In Best Practices**: AWS CDK incorporates AWS best practices by default, helping users adhere to security, reliability, and efficiency standards without having to be experts in AWS. It intelligently selects resource types and configurations that meet AWS guidelines.
6. **Aspects**: AWS CDK aspects apply standards to all constructs within a scope by modifying constructs, such as adding tags, or verifying their state.
7. **CLI and Programmatic Toolkit**: The AWS CDK Toolkit provides both a command-line tool, the CDK CLI, and a programmatic library, the CDK Toolkit Library, for managing and interacting with CDK apps.

## Where AWS Cloud Development Kit (AWS CDK) is used

AWS CDK enables infrastructure as code, automated deployments, reusable component libraries, serverless application definition, and simplified permission management and security, enhancing cloud development and operability.

1. **Infrastructure as Code for Cloud Resources**: AWS CDK allows developers to define their cloud resources using familiar programming languages. This approach to infrastructure as code (IaC) helps in automating deployment and managing infrastructure through versioned code without manually handling resource provisioning.
2. **Automated Cloud Application Deployment**: With AWS CDK, developers can automatically deploy cloud applications. By scripting the deployment process, AWS CDK simplifies continuous integration and continuous delivery (CI/CD) pipelines, ensuring applications are deployed consistently and with less manual overhead.
3. **Reusable Cloud Component Libraries**: AWS CDK supports the creation of reusable component libraries. These libraries can be shared within an organization, allowing teams to rapidly deploy standardized and proven cloud infrastructure patterns, improving development speed and reducing errors.
4. **Serverless Applications**: AWS CDK is instrumental in defining serverless applications. Developers can use high-level abstractions to define functions, APIs, and event source mappings, making it easier to build and deploy serverless architectures on AWS Lambda and related services.
5. **Permission Management and Security**: Managing permissions and security settings is streamlined with AWS CDK. It provides constructs for defining AWS Identity and Access Management (IAM) roles, policies, and security groups, making it simpler to implement best practices for cloud security.

## How AWS Cloud Development Kit (AWS CDK) is priced

AWS CDK is free to use, with costs only occurring for the AWS services provisioned via the CDK.

- **Free-to-use Model**: AWS CDK itself does not incur direct costs for its usage. Developers are only charged for the AWS resources they provision through the CDK based on the pricing of individual AWS services.

## Services AWS Cloud Development Kit (AWS CDK) works with

- **[Amazon S3](https://blowstack.com/tools/cloud-services-hub/amazon-s3)**: CDK allows you to create, configure, and manage S3 buckets for object storage.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: CDK facilitates the creation and deployment of serverless functions using AWS Lambda.
- **[Amazon DynamoDB](https://blowstack.com/tools/cloud-services-hub/amazon-dynamodb)**: CDK supports defining and managing NoSQL databases with DynamoDB tables.
- **[Amazon RDS](https://blowstack.com/tools/cloud-services-hub/amazon-rds)**: CDK helps provision and manage relational database instances using RDS.
- **[Amazon EC2](https://blowstack.com/tools/cloud-services-hub/amazon-ec2)**: CDK enables the setup and management of virtual servers and associated resources using EC2.
- **[Amazon Elastic Container Registry (Amazon ECR)](https://blowstack.com/tools/cloud-services-hub/amazon-elastic-container-registry-(amazon-ecr))**: AWS CDK publishes Docker image assets to Amazon ECR repositories during deployment. Deployed resources can then use those images, such as a container image built from a local directory for an ECS task.
- **[AWS Amplify](https://blowstack.com/tools/cloud-services-hub/aws-amplify)**: Amplify Gen 2 builds backend infrastructure using AWS CDK. You can extend an Amplify backend with CDK constructs and connect additional resources to its generated authentication, data, and storage resources.
- **[AWS CloudFormation](https://blowstack.com/tools/cloud-services-hub/aws-cloudformation)**: AWS CDK synthesizes application stacks into CloudFormation templates and deploys them through CloudFormation. CloudFormation provisions the resources, tracks stack state, and handles updates and rollbacks.
- **[AWS CodeBuild](https://blowstack.com/tools/cloud-services-hub/aws-codebuild)**: CDK Pipelines uses CodeBuild projects to synthesize CDK applications, publish assets, and update the pipeline itself. Build steps can also run application tests and deployment validation commands.
- **[AWS CodeCommit](https://blowstack.com/tools/cloud-services-hub/aws-codecommit)**: CDK Pipelines supports CodeCommit repositories as pipeline sources. Changes to a configured repository branch can start a pipeline that synthesizes and deploys the CDK application.
- **[AWS CodeConnections](https://blowstack.com/tools/cloud-services-hub/aws-codeconnections)**: CDK Pipelines supports CodeConnections connections as sources for repositories hosted by supported external providers. The connection supplies source revisions to the pipeline that builds and deploys the CDK application.
- **[AWS CodePipeline](https://blowstack.com/tools/cloud-services-hub/aws-codepipeline)**: CDK Pipelines creates CodePipeline pipelines that synthesize and deploy CDK applications across stages, accounts, and Regions. Its self-mutation step updates the pipeline when the application's pipeline definition changes.
- **[AWS Key Management Service (AWS KMS)](https://blowstack.com/tools/cloud-services-hub/aws-key-management-service-(aws-kms))**: CDK Pipelines can use customer-managed KMS keys to encrypt pipeline artifacts, including when artifacts must be shared across accounts. CDK bootstrapping also supports configuring a KMS key for its staging bucket.
- **[AWS Security Token Service (AWS STS)](https://blowstack.com/tools/cloud-services-hub/aws-security-token-service-(aws-sts))**: AWS CDK uses STS to assume bootstrapped roles for deployments, asset publishing, and environment lookups. This lets a deployment process obtain temporary credentials for a target account rather than use permanent credentials for each deployment role.
- **[AWS Systems Manager](https://blowstack.com/tools/cloud-services-hub/aws-systems-manager)**: AWS CDK bootstrapping records the bootstrap version in Systems Manager Parameter Store, allowing deployments to verify that required bootstrap capabilities are available. CDK applications can also look up Parameter Store values during synthesis and cache them as context.

## What is AWS Cloud Development Kit (AWS CDK)

The AWS Cloud Development Kit, also known as AWS CDK, represents a significant leap forward in how cloud resources are provisioned and managed, offering a more dynamic, flexible, and efficient approach to utilizing Amazon Web Services (AWS).

At its core, the AWS CDK is a software development framework that allows developers to define their cloud infrastructure using familiar programming languages such as TypeScript, Python, Java, and C#. This innovative approach moves away from the traditional JSON or YAML templates used in AWS CloudFormation, towards a more intuitive and developer-friendly model that leverages the power of modern programming practices.

One of the defining features of the AWS CDK is its ability to enable developers to compose and share their own custom cloud components. What this means in practice is that teams can build and distribute higher-level abstractions that encapsulate cloud best practices or specific business logic, codifying and reusing patterns effectively across their organization. This not only accelerates the development process by reducing redundant effort but also ensures consistency and compliance with organizational standards.

A CDK app defines one or more stacks, each equivalent to a CloudFormation stack. Each stack contains constructs that define one or more AWS resources.

The AWS CDK integrates deeply with AWS CloudFormation, providing a seamless deployment mechanism. When a developer provisions infrastructure using the CDK, under the hood, the CDK synthesizes CloudFormation templates from the code. This synthesis process converts the higher-level abstraction provided by the CDK into the detailed specification required by CloudFormation to deploy and manage AWS resources. Notably, this dual-layer approach combines the abstract, developer-friendly interface of the CDK with the robust, proven deployment capabilities of CloudFormation, offering the best of both worlds.

CDK checks stack resource counts during synthesis and warns when a stack exceeds 80% of the CloudFormation resource limit. The stack's `maxResources` property sets a different resource limit for validation; setting it to `0` disables validation.

Another significant advantage of using the AWS CDK is the built-in best practices that come with it. AWS provides a library of pre-built constructs, which are the basic building blocks in the CDK, representing AWS resources and their configurations. These constructs are designed to guide users toward well-architected solutions, automatically handling intricate details such as security configurations, resource dependencies, and other cloud-specific considerations that might otherwise be overlooked.

The AWS CDK also promotes the Infrastructure as Code (IaC) paradigm, allowing entire cloud infrastructure setups to be version-controlled alongside application code. This facilitates better collaboration among team members, simplifies the rollback of changes, and enhances the overall auditability of the infrastructure. Coupled with the power of modern integrated development environments (IDEs) and tools, developers can enjoy features like code completion, syntax highlighting, and error detection in real-time as they define their cloud infrastructure, making the process both more efficient and less prone to errors.

In summary, the AWS Cloud Development Kit is a powerful tool that modernizes cloud infrastructure provisioning by marrying conventional coding practices with cloud resource management. It not only streamlines the development and deployment processes but also encourages best practices and consistency across teams and projects. As cloud computing continues to evolve, tools like the AWS CDK will play an instrumental role in shaping the future of how applications and services are deployed in the cloud.

## AWS Cloud Development Kit (AWS CDK) exam questions

Real practice exam questions on AWS Cloud Development Kit (AWS CDK), with the correct answer and its explanation.

### Question 1 (SOA-C03)

**Question:**

A company uses a shared construct library in a TypeScript AWS CDK application. The library creates an Amazon S3 bucket by using an L2 Bucket construct and exposes that construct to the application. The bucket is already deployed without versioning. The shared library does not provide an option to enable versioning.

A CloudOps engineer must enable versioning on the existing bucket through the application's CDK source code without modifying the shared library or creating another bucket. The deployment pipeline regenerates the CloudFormation template from the application before every deployment.

Which solution meets these requirements?

**Correct answer:** Access the exposed Bucket construct's node.defaultChild, cast it to CfnBucket, and set its versioningConfiguration status to Enabled before synthesis.

**Explanation:** The L2 Bucket construct contains an underlying L1 CfnBucket resource. Using this escape hatch changes the properties synthesized for the same CloudFormation resource. CloudFormation can enable versioning on the existing bucket in place, and the change remains reproducible from the application's source code.

### Question 2 (SAP-C03)

**Question:**

A company uses AWS CDK applications to define infrastructure for several environments. Each application contains multiple CDK Stage constructs, and each Stage contains several stacks. Teams create S3 buckets by using company libraries, third-party constructs, and low-level CloudFormation resource constructs.

A new policy requires every bucket defined by these applications to have versioning explicitly enabled. All versioning settings are concrete values available during synthesis. The platform team must provide a reusable control that reports each violation with its construct path and causes pull-request validation to fail before any deployment. Validation must run without AWS credentials or access to AWS service endpoints. The control must not silently modify resource settings.

Which solution best meets these requirements?

**Correct answer:** Create a reusable CDK aspect that inspects every CfnBucket and adds an error annotation when versioning is not explicitly enabled. Attach the aspect to each Stage, and require successful synthesis in pull-request validation.

**Explanation:** An aspect can inspect the construct tree during synthesis. Inspecting CfnBucket resources covers buckets created through higher-level libraries as well as directly through low-level constructs. Error annotations identify offending construct paths and cause synthesis to fail without modifying resources. Aspects do not propagate across Stage boundaries, so attaching the aspect to each Stage ensures coverage of its stacks. These checks can run locally without AWS API calls.

### Question 3 (DEA-C01)

**Question:**

A data engineering team uses AWS CDK to deploy AWS Glue jobs from a dataset configuration file. The application creates each job with a construct ID that includes the dataset name and the current timestamp. CloudFormation generates the physical job names. Each deployment targets the same stack in the same account and Region.

The CI/CD system sometimes reruns deployment after losing its connection, even when the previous deployment completed successfully. The team notices that deploying unchanged code and configuration produces new Glue jobs and removes the previous jobs.

Which change will ensure that repeated deployments of unchanged code and configuration preserve the existing jobs without requiring manual intervention?

**Correct answer:** Use a stable construct ID derived from each dataset's unique configuration key, and keep the construct hierarchy unchanged between deployments.

**Explanation:** CDK derives CloudFormation logical IDs from construct paths. Stable construct IDs and hierarchy preserve resource identity. When the code and configuration are unchanged, repeated deployments target the existing jobs instead of creating replacements, making retries safe.

### Question 4 (AIP-C01)

**Question:**

A platform team supports several AWS CDK applications for Amazon Bedrock document-processing workloads. Each application defines development and production environments as separate CDK Stage constructs. The stages contain stacks built from team-owned constructs, third-party constructs, and low-level CloudFormation resource constructs.

A new security standard requires every Amazon S3 bucket defined by these applications to explicitly enable all four S3 Block Public Access settings. Existing construct implementations cannot be rewritten. All deployments run through a controlled pipeline, which must reject noncompliant infrastructure during CDK synthesis, before any deployment API calls occur. The platform team wants one centrally maintained implementation of this check.

Which solution best meets these requirements?

**Correct answer:** Publish a shared CDK Aspect that inspects every CfnBucket and adds an error annotation unless all four Block Public Access settings are explicitly true. Apply the Aspect to each environment Stage and configure the pipeline to stop when CDK synthesis reports errors.

**Explanation:** An Aspect can inspect low-level resources created by team-owned, third-party, and directly instantiated constructs without rewriting their implementations. Applying it to each Stage covers the resources within those stages because Aspects do not propagate across Stage boundaries. Error annotations cause synthesis to fail, allowing the pipeline to reject the configuration before deployment.

### Question 5 (DVA-C02)

**Question:**

A developer maintains a TypeScript AWS CDK application that defines exactly one Amazon DynamoDB table. The team's infrastructure requirements specify on-demand billing and point-in-time recovery for the table. A CI job must reject changes that violate either requirement before any resources are deployed. The job has no AWS credentials, and the CDK application does not perform AWS environment lookups.

Which solution meets these requirements?

**Correct answer:** Add a unit test that instantiates the CDK stack and uses `Template.fromStack` from `aws-cdk-lib/assertions`. Assert that the `AWS::DynamoDB::Table` resource has `BillingMode` set to `PAY_PER_REQUEST` and `PointInTimeRecoverySpecification.PointInTimeRecoveryEnabled` set to `true`. Require the test to pass in CI.

**Explanation:** CDK assertions can inspect the synthesized CloudFormation template and verify specific resource properties without deploying resources. Because the application performs no AWS environment lookups, this test can run without AWS credentials and fail CI if either required setting is absent or incorrect.

### Question 6 (DOP-C02)

**Question:**

A company uses an AWS CDK v2 TypeScript application to deploy EC2 workloads into several explicitly configured account and Region environments. A reusable construct selects the newest golden AMI by using MachineImage.lookup with a name filter and a trusted image-owner account. All target environments have been synthesized successfully, and the application requires no other AWS lookups.

The image team regularly publishes new AMIs that match the filter. Security requires each infrastructure release to continue selecting the previously approved AMI until a separate image-update pull request is approved. Routine CI synthesis must run without target-account credentials. The platform team must retain the lookup-based construct and avoid maintaining a separate inventory of AMI IDs.

Which solution meets these requirements with the LEAST operational overhead?

**Correct answer:** Commit cdk.context.json to version control. Run routine CI synthesis with lookups disabled. For an image-update pull request, reset the relevant AMI lookup context entries and synthesize the affected environments with authorized lookup credentials, then commit and review the refreshed context results.

**Explanation:** MachineImage.lookup resolves the AMI during synthesis and caches the result in CDK context. Versioning cdk.context.json preserves the selected AMI for each environment and allows subsequent synthesis without lookup credentials. Disabling lookups makes CI fail rather than silently retrieving an unreviewed result if required context is missing. Deliberately resetting and repopulating the relevant entries makes image changes explicit and reviewable.

### Question 7 (ANS-C01)

**Question:**

A company uses an AWS CDK application to manage a production VPC, subnets, route tables, and routes in one CloudFormation stack. A network engineer moves the existing resource definitions into a reusable CDK construct without changing their properties, account, Region, or stack. After the refactoring, cdk diff shows that existing resources will be removed and new resources will be added because their synthesized logical IDs have changed. The company requires the deployed resources to remain under management by the same stack without being recreated. The engineer must use the normal cdk deploy workflow. Which solution meets these requirements?

**Correct answer:** Map each affected resource to its original logical ID and apply overrideLogicalId to its underlying L1 CDK resource. Verify that the synthesized template preserves the existing resource identities and properties before deploying.

**Explanation:** CloudFormation tracks resources within a stack by logical ID. Overriding the affected L1 resources' logical IDs with their original values preserves their identities despite the changed construct paths. With the resource properties also unchanged, the refactoring does not require recreation. Reviewing the synthesized template and diff verifies that the mapping is complete.

## Practice AWS Cloud Development Kit (AWS CDK) in a full exam

Questions on AWS Cloud Development Kit (AWS CDK) in each practice exam, with every answer option and an explanation for each:

- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 13 questions
- [SOA-C03](https://blowstack.com/practice-exams/aws-certified-cloudops-engineer-associate): 10 questions
- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 5 questions
- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 4 questions
- [ANS-C01](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty): 4 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 2 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 2 questions

## Learn AWS Cloud Development Kit (AWS CDK) in lessons

11 short lessons on AWS Cloud Development Kit (AWS CDK) in 5 certification courses.

- SOA-C03: AWS CDK: stack deployment lifecycle (Premium), https://app.blowstack.com/lessons/aws-cdk-stack-deployment-lifecycle-soa-c03
- SAP-C03: AWS Cloud Development Kit (AWS CDK): predictable stack synthesis (Premium), https://app.blowstack.com/lessons/aws-cloud-development-kit-aws-cdk-predictable-stack-synthesis-sap-c03
- DEA-C01: AWS CDK: repeatable stack deployment (Premium), https://app.blowstack.com/lessons/aws-cdk-repeatable-stack-deployment-dea-c01
- AIP-C01: AWS CDK: reusable construct libraries (Premium), https://app.blowstack.com/lessons/aws-cdk-reusable-construct-libraries-aip-c01
- DOP-C02: AWS CDK: from application code to deployed stacks (Premium), https://app.blowstack.com/lessons/aws-cdk-from-application-code-to-deployed-stacks-dop-c02
- SOA-C03: AWS CDK and AWS CloudFormation: authoring versus provisioning (Premium), https://app.blowstack.com/lessons/aws-cdk-and-aws-cloudformation-authoring-versus-provisioning-soa-c03
