AWS CDK in Action — May 2025: Empowered Deployments, Governance, and Community

In May 2025, AWS CDK introduced enhancements—especially around the Toolkit Library—to help you build custom tools, enable best practices, and automatic drift detection. Here are some of the top launches from CDK in May. 1: Programmatic Access with the Toolkit Library (GA) The CDK Toolkit Library enables you to perform CDK actions programmatically through code instead of using CLI commands. You can use this library to create custom tools, build specialized CLI applications, and integrate CDK capabilities into your development workflows. Getting Started with the Toolkit Library The following example shows how to create and deploy a simple S3 bucket using the CDK Toolkit Library: // Import required packages import { Toolkit } from '@aws-cdk/toolkit-lib'; import { App, Stack } from 'aws-cdk-lib'; import * as s3 from 'aws-cdk-lib/aws-s3'; // Create and configure the CDK Toolkit const toolkit = new Toolkit(); // Create a cloud assembly source with an inline app const cloudAssemblySource = await toolkit.fromAssemblyBuilder(async () => { const app = new App(); const stack = new Stack(app, 'SimpleStorageStack'); // Create an S3 bucket in the stack new s3.Bucket(stack, 'MyFirstBucket', { versioned: true }); return app.synth(); }); // Deploy the stack await toolkit.deploy(cloudAssemblySource); Use the Toolkit Library to build robust, integrated CI/CD pipelines, developer tools, or dashboards—no CLI wrappers required. Read more here. Keep reading to see how AWS Amplify uses toolkits to improve developer experience! 2: Ensuring Reliability with Drift Detection Imagine shipping a small tag update directly in the console—only to later discover that a stack's configuration no longer matches your CDK code. The cdk drift command empowers you to identify these out-of-band changes before they impact production. How it works: cdk drift uses CloudFormation’s Detect Stack Drift API to compare your deployed stack against its CDK-defined template. Usage in CI: npx cdk drift --fail checks for drift and fails if discrepancies are found. Programmatic Access: You can also call Toolkit.drift() programmatically via the Toolkit Library, enabling integrated drift checks in custom scripts. By proactively detecting drift, you reduce unexpected downtime and maintain confidence in your deployments. Read more here. 3: Enable Best-Practices with Property Injection (Preview) CDK launched Property Injection so your organization can standardize default construct properties—providing a template for builders to follow best practices while retaining full flexibility to override. Builders can import these recommended defaults into their app, while having the flexibility to override them if needed. First, create a property injector for Amazon S3 buckets: import { IPropertyInjector, InjectionContext } from 'aws-cdk-lib'; import { Bucket, BucketProps, BlockPublicAccess } from 'aws-cdk-lib/aws-s3'; export class SecureBucketDefaults implements IPropertyInjector { public readonly constructUniqueId: string; constructor() { this.constructUniqueId = Bucket.PROPERTY_INJECTION_ID; } public inject(originalProps: BucketProps, _context: InjectionContext): BucketProps { return { // Set security defaults blockPublicAccess: BlockPublicAccess.BLOCK_ALL, enforceSSL: true, // Include original props to allow overrides ...originalProps, }; } } Then, use the injector in your CDK application: import { App, Stack } from 'aws-cdk-lib'; import { Bucket } from 'aws-cdk-lib/aws-s3'; import { SecureBucketDefaults } from './secure-bucket-defaults'; // Attach injectors when creating the App const app = new App({ propertyInjectors: [new SecureBucketDefaults()] }); const stack = new Stack(app, 'MyStack'); // This bucket automatically gets the default properties const myBucket = new Bucket(stack, 'MyBucket'); Apply injectors at the App, Stage, or Stack level. Read more here. 4: AWS Amplify CDK Toolkit-Powered Sandboxes Amplify’s sandbox now integrates with the CDK Toolkit Library directly (PR #2503). CDK Toolkit emits structured JSON events for synth, diff, deploy, etc. Because the Toolkit Library returns typed results, Amplify (or any other tool calling CDK) no longer has to parse raw text - and can take full control of their own output and presentation. Read more here 5: Community stars Collaboration fuels innovation. In May, two community contributions stood out: Deepu Mohan Puthrote contributed OidcProviderNativeConstruct here. Thanks for working with the CDK team on getting this important feature in! Kenta Goto, one of our top community contributors and AWS dev tools Heroes, wrote a very helpful article on property injectors in CDK. Want to share your story? Tag posts with #awsCDK or publish on https://cdk.dev/posts to be featured next month. That’s the story of May 2025—building integrated tooling, enablin

Jun 13, 2025 - 04:20
 0
AWS CDK in Action — May 2025: Empowered Deployments, Governance, and Community

In May 2025, AWS CDK introduced enhancements—especially around the Toolkit Library—to help you build custom tools, enable best practices, and automatic drift detection. Here are some of the top launches from CDK in May.

1: Programmatic Access with the Toolkit Library (GA)

The CDK Toolkit Library enables you to perform CDK actions programmatically through code instead of using CLI commands. You can use this library to create custom tools, build specialized CLI applications, and integrate CDK capabilities into your development workflows.

Getting Started with the Toolkit Library

The following example shows how to create and deploy a simple S3 bucket using the CDK Toolkit Library:

// Import required packages
import { Toolkit } from '@aws-cdk/toolkit-lib';
import { App, Stack } from 'aws-cdk-lib';
import * as s3 from 'aws-cdk-lib/aws-s3';

// Create and configure the CDK Toolkit
const toolkit = new Toolkit();

// Create a cloud assembly source with an inline app
const cloudAssemblySource = await toolkit.fromAssemblyBuilder(async () => {
const app = new App();
const stack = new Stack(app, 'SimpleStorageStack');

// Create an S3 bucket in the stack
new s3.Bucket(stack, 'MyFirstBucket', {
versioned: true
});

return app.synth();
});

// Deploy the stack
await toolkit.deploy(cloudAssemblySource);

Use the Toolkit Library to build robust, integrated CI/CD pipelines, developer tools, or dashboards—no CLI wrappers required. Read more here. Keep reading to see how AWS Amplify uses toolkits to improve developer experience!

2: Ensuring Reliability with Drift Detection

Imagine shipping a small tag update directly in the console—only to later discover that a stack's configuration no longer matches your CDK code. The cdk drift command empowers you to identify these out-of-band changes before they impact production.

  • How it works: cdk drift uses CloudFormation’s Detect Stack Drift API to compare your deployed stack against its CDK-defined template.
  • Usage in CI: npx cdk drift --fail checks for drift and fails if discrepancies are found.
  • Programmatic Access: You can also call Toolkit.drift() programmatically via the Toolkit Library, enabling integrated drift checks in custom scripts.

By proactively detecting drift, you reduce unexpected downtime and maintain confidence in your deployments. Read more here.

3: Enable Best-Practices with Property Injection (Preview)

CDK launched Property Injection so your organization can standardize default construct properties—providing a template for builders to follow best practices while retaining full flexibility to override. Builders can import these recommended defaults into their app, while having the flexibility to override them if needed.

First, create a property injector for Amazon S3 buckets:

import { IPropertyInjector, InjectionContext } from 'aws-cdk-lib';
import { Bucket, BucketProps, BlockPublicAccess } from 'aws-cdk-lib/aws-s3';

export class SecureBucketDefaults implements IPropertyInjector {
  public readonly constructUniqueId: string;

  constructor() {
    this.constructUniqueId = Bucket.PROPERTY_INJECTION_ID;
  }

  public inject(originalProps: BucketProps, _context: InjectionContext): BucketProps {
    return {
      // Set security defaults
      blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
      enforceSSL: true,

      // Include original props to allow overrides
      ...originalProps,
    };
  }
}

Then, use the injector in your CDK application:

import { App, Stack } from 'aws-cdk-lib';
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { SecureBucketDefaults } from './secure-bucket-defaults';

// Attach injectors when creating the App
const app = new App({
  propertyInjectors: [new SecureBucketDefaults()]
});

const stack = new Stack(app, 'MyStack');

// This bucket automatically gets the default properties
const myBucket = new Bucket(stack, 'MyBucket');

Apply injectors at the App, Stage, or Stack level. Read more here.

4: AWS Amplify CDK Toolkit-Powered Sandboxes

Amplify’s sandbox now integrates with the CDK Toolkit Library directly (PR #2503). CDK Toolkit emits structured JSON events for synth, diff, deploy, etc.
Because the Toolkit Library returns typed results, Amplify (or any other tool calling CDK) no longer has to parse raw text - and can take full control of their own output and presentation. Read more here

5: Community stars

Collaboration fuels innovation. In May, two community contributions stood out:

  1. Deepu Mohan Puthrote contributed OidcProviderNativeConstruct here. Thanks for working with the CDK team on getting this important feature in!
  2. Kenta Goto, one of our top community contributors and AWS dev tools Heroes, wrote a very helpful article on property injectors in CDK.

Want to share your story? Tag posts with #awsCDK or publish on https://cdk.dev/posts to be featured next month.

That’s the story of May 2025—building integrated tooling, enabling best practices, and celebrating community achievements. Share your feedback and happy building!