Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Building AWS CDK applications with AWS SAM

Focus mode
Building AWS CDK applications with AWS SAM - AWS Cloud Development Kit (AWS CDK) v2

This is the AWS CDK v2 Developer Guide. The older CDK v1 entered maintenance on June 1, 2022 and ended support on June 1, 2023.

This is the AWS CDK v2 Developer Guide. The older CDK v1 entered maintenance on June 1, 2022 and ended support on June 1, 2023.

The AWS SAM CLI provides support for building Lambda functions and layers defined in your AWS CDK application with sam build.

For Lambda functions that use zip artifacts, run cdk synth before you run sam local commands. sam build isn't required.

If your AWS CDK application uses functions with the image type, run cdk synth and then run sam build before you run sam local commands. When you run sam build, AWS SAM doesn't build Lambda functions or layers that use runtime-specific constructs, for example, NodejsFunction. sam build doesn't support bundled assets.

Example

Running the following command from the AWS CDK project root directory builds the application.

$ sam build -t ./cdk.out/CdkSamExampleStack.template.json

On this page

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.