Back to Releases
v2.224.0 2025年11月13日

AWS CDK v2.224.0 リリース解説

API Gatewayの権限統合、Lambda Node.js 24.x、EKS 1.34、SageMaker Serverless推論、Secrets Managerの動的参照キー取得メソッドなどの新機能を含むリリース

apigatewaylambdaekssagemakerstepfunctionssecretsmanagerimagebuilder

概要

AWS CDK v2.224.0では、API GatewayのLambda権限統合、Lambda Node.js 24.xランタイムのサポート、Amazon EKS 1.34のサポート、SageMaker Serverless推論エンドポイントのサポートなど、多くの新機能が追加されました。また、Secrets Managerの動的参照キーを取得するための新しいメソッドも追加されています。

破壊的変更

参照インターフェースの移動

参照インターフェース(IBucketRef, IRoleRefなど)が新しいaws-cdk-lib.interfacesサブモジュールに移動されました。これはサービスモジュール間の循環依存を防ぐための変更です。

参照インターフェースをインポートしている場合は、インポート文を更新する必要があります。詳細は#36060を参照してください。

.NETネームスペースの変更

.NETユーザーの場合、複数のサブモジュールのネームスペースが変更されました。名前が変更されたサブモジュールを使用している場合は、using文を更新する必要があります。詳細は#36037を参照してください。

L1リソースの更新

以下のL1リソースに互換性のない変更が含まれています:

  • aws-opensearchserverless: AWS::OpenSearchServerless::CollectionStandbyReplicasプロパティがimmutableになりました
  • aws-servicecatalog: AWS::ServiceCatalog::PortfolioPrincipalAssociationId属性が削除されました

新機能

API Gateway: Lambda権限の統合オプション

API GatewayでLambda関数を複数のオペレーションで再利用する場合、各オペレーションごとに新しい権限が追加され、Lambdaの権限ポリシーサイズの上限(20KB)を超える可能性がありました。

このリリースでは、REST APIおよびHTTP APIのLambda統合に、権限を単一のステートメントに統合するオプションが追加されました。

REST API:

import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as apigateway from 'aws-cdk-lib/aws-apigateway';

declare const handler: lambda.Function;
declare const api: apigateway.RestApi;

// Lambda関数を複数のメソッドで使用する場合
const integration = new apigateway.LambdaIntegration(handler, {
  // falseに設定すると、API全体に対して1つの権限のみが作成される
  scopePermissionToMethod: false,  // デフォルト: true(各メソッドごとに権限を作成)
});

api.root.addMethod('GET', integration);
api.root.addMethod('POST', integration);

HTTP API:

import * as lambda from 'aws-cdk-lib/aws-lambda';
import { HttpApi } from 'aws-cdk-lib/aws-apigatewayv2';
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

declare const handler: lambda.Function;
declare const api: HttpApi;

// HTTP APIでも同様の設定が可能
const integration = new HttpLambdaIntegration('Integration', handler, {
  // falseに設定すると、API全体に対して1つの権限のみが作成される
  scopePermissionToRoute: false,  // デフォルト: true(各ルートごとに権限を作成)
});

api.addRoutes({
  path: '/items',
  methods: [HttpMethod.GET, HttpMethod.POST],
  integration,
});

権限のスコープの違い:

  • true(デフォルト): 各メソッド/ルートごとに個別の権限が作成され、特定のリソース/メソッド/ステージにスコープされる
  • false: API全体に対して1つの権限が作成され、任意のリソース/メソッド/ステージにスコープされる

PR #36021

Secrets Manager: 動的参照キーの取得メソッド

CloudFormationの動的参照を使用すると、AWS Secrets Managerのシークレットを他のAWS CloudFormationリソースで取得できます。これまでは、動的参照のキー文字列を文字列操作で作成する必要がありました。

このリリースでは、SecretValueSecretクラスに動的参照キーを取得するための新しいメソッドが追加されました。

SecretValue静的メソッド:

import { SecretValue } from 'aws-cdk-lib';
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';

declare const mySecret: secretsmanager.Secret;

// 動的参照キー文字列を生成
const passwordKey = SecretValue.cfnDynamicReferenceKey(
  mySecret.secretArn,
  {
    jsonField: 'password',  // JSONフィールド名(オプション)
  }
);

// 結果: "{{resolve:secretsmanager:arn:aws:secretsmanager:...:SecretString:password}}"

Secretインスタンスメソッド:

import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';

declare const mySecret: secretsmanager.Secret;

// Secretインスタンスから直接動的参照キーを取得
const passwordKey = mySecret.cfnDynamicReferenceKey({
  jsonField: 'password',  // JSONフィールド名(オプション)
});

// 全体のシークレット文字列を取得する場合
const fullSecretKey = mySecret.cfnDynamicReferenceKey();

これにより、CloudFormationテンプレート内で動的参照を使用する際のコードが簡潔になります。

PR #35105

Amazon EKS: Kubernetes 1.34のサポート

Amazon EKSがKubernetes version 1.34をサポートしたことに伴い、CDKでも1.34のサポートが追加されました。

import * as eks from 'aws-cdk-lib/aws-eks';
import { KubectlV34Layer } from '@aws-cdk/lambda-layer-kubectl-v34';

const cluster = new eks.Cluster(this, 'MyCluster', {
  version: eks.KubernetesVersion.V1_34,  // Kubernetes 1.34
  kubectlLayer: new KubectlV34Layer(this, 'KubectlLayer'),
});

この変更は純粋に追加的なもので、既存のバージョン(1.29-1.33)との完全な下位互換性が維持されています。

PR #36016

AWS Lambda: Node.js 24.xランタイムのサポート

Lambda関数でNode.js 24.xランタイムが利用可能になりました。

import * as lambda from 'aws-cdk-lib/aws-lambda';

const fn = new lambda.Function(this, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_24_X,  // Node.js 24.x
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda'),
});

PR #36001

Amazon SageMaker: Serverless推論エンドポイントのサポート

間欠的または予測不可能なトラフィックパターンに対してコスト効率の高いSageMaker Serverless推論エンドポイントがサポートされました。

import * as sagemaker from '@aws-cdk/aws-sagemaker-alpha';

declare const model: sagemaker.IModel;

// Serverless推論エンドポイントの設定
const endpointConfig = new sagemaker.EndpointConfig(this, 'ServerlessEndpointConfig', {
  serverlessProductionVariant: {
    model: model,
    variantName: 'serverlessVariant',
    maxConcurrency: 10,              // 最大同時実行数(1-200、必須)
    memorySizeInMB: 2048,            // メモリサイズ(1024-6144MB、1GB単位、必須)
    provisionedConcurrency: 5,       // プロビジョニング済み同時実行数(オプション、maxConcurrency以下)
  },
});

const endpoint = new sagemaker.Endpoint(this, 'ServerlessEndpoint', {
  endpointConfig,
});

設定パラメータ:

  • maxConcurrency: 最大同時実行数(範囲: 1-200、必須)
  • memorySizeInMB: メモリサイズ(範囲: 1024-6144MB、1GB単位、必須)
  • provisionedConcurrency: プロビジョニング済み同時実行数(範囲: 1-200、オプション、maxConcurrency以下である必要がある)

制約事項:

  • エンドポイント設定ごとに1つのServerlessバリアントのみサポート
  • インスタンスベースのバリアントとServerlessバリアントは相互排他的

PR #35557

Step Functions: EvaluateExpressionでのアーキテクチャサポート

EvaluateExpressionコンストラクトで、Lambda関数のアーキテクチャ(ARM64またはX86_64)を指定できるようになりました。ARM64を使用することで、特定のワークロードにおいて優れた価格性能比を得られる場合があります。

import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
import * as lambda from 'aws-cdk-lib/aws-lambda';

// ARM64アーキテクチャを使用
const evalTask = new tasks.EvaluateExpression(this, 'EvalExpression', {
  expression: '$.a + $.b',
  architecture: lambda.Architecture.ARM_64,  // ARM64を指定(コスト効率向上)
});

// X86_64アーキテクチャを明示的に指定
const evalTaskX86 = new tasks.EvaluateExpression(this, 'EvalExpressionX86', {
  expression: '$.a * $.b',
  architecture: lambda.Architecture.X86_64,  // X86_64を指定
});

// アーキテクチャを指定しない場合はデフォルト(X86_64)が使用される
const evalTaskDefault = new tasks.EvaluateExpression(this, 'EvalExpressionDefault', {
  expression: '$.a - $.b',
  // architecture未指定の場合、デフォルトでX86_64が使用される
});

PR #35468

Alphaモジュール

EC2 Image Builder: Infrastructure Configuration L2コンストラクト (Alpha)

EC2 Image BuilderのInfrastructure Configuration L2コンストラクトが新しいalphaモジュール(@aws-cdk/aws-imagebuilder-alpha)に追加されました。

import * as imagebuilder from '@aws-cdk/aws-imagebuilder-alpha';
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as iam from 'aws-cdk-lib/aws-iam';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as s3 from 'aws-cdk-lib/aws-s3';

declare const vpc: ec2.Vpc;

const infrastructureConfiguration = new imagebuilder.InfrastructureConfiguration(
  this,
  'InfrastructureConfiguration',
  {
    infrastructureConfigurationName: 'my-infrastructure-config',
    description: 'Infrastructure configuration for image builder',

    // ビルド/テストに使用するインスタンスタイプ(オプション)
    instanceTypes: [
      ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.LARGE),
      ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.XLARGE),
    ],

    // 必要な権限を持つインスタンスプロファイル(オプション)
    instanceProfile: new iam.InstanceProfile(this, 'InstanceProfile', {
      role: new iam.Role(this, 'InstanceProfileRole', {
        assumedBy: new iam.ServicePrincipal('ec2.amazonaws.com'),
        managedPolicies: [
          iam.ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore'),
          iam.ManagedPolicy.fromAwsManagedPolicyName('EC2InstanceProfileForImageBuilder'),
        ],
      }),
    }),

    // VPCネットワーク設定
    vpc,
    subnetSelection: { subnetType: ec2.SubnetType.PUBLIC },
    securityGroups: [
      ec2.SecurityGroup.fromSecurityGroupId(this, 'SecurityGroup', vpc.vpcDefaultSecurityGroup),
    ],

    // SSHキーペア(オプション)
    keyPair: ec2.KeyPair.fromKeyPairName(this, 'KeyPair', 'my-key-pair'),

    // 失敗時にインスタンスを終了(オプション、デフォルト: true)
    terminateInstanceOnFailure: true,

    // IMDSv2設定(オプション)
    httpTokens: imagebuilder.HttpTokens.REQUIRED,  // IMDSv2を必須化
    httpPutResponseHopLimit: 1,                     // ホップ制限

    // イメージ完了通知用のSNSトピック(オプション)
    notificationTopic: sns.Topic.fromTopicArn(
      this,
      'Topic',
      'arn:aws:sns:us-east-1:123456789012:image-builder-topic'
    ),

    // ログ設定(オプション、デフォルトで有効)
    logging: {
      s3Bucket: s3.Bucket.fromBucketName(this, 'LogBucket', 'my-log-bucket'),
      s3KeyPrefix: 'imagebuilder-logs/',  // S3キープレフィックス
    },

    // ホスト配置設定(オプション)
    ec2InstanceAvailabilityZone: 'us-east-1a',
    ec2InstanceTenancy: imagebuilder.Tenancy.DEFAULT,

    // リソースタグ(オプション)
    resourceTags: {
      Environment: 'production',
      Team: 'platform',
    },
  }
);

このL2コンストラクトは、CfnInfrastructureConfigurationの高レベル抽象化を提供し、より使いやすいAPIでImage Builderのインフラストラクチャ設定を定義できます。

PR #35882

バグ修正

aws-cdk-lib: 参照インターフェースのサブモジュール移動

サービスモジュール間の循環依存を防ぐため、参照インターフェースが専用のサブモジュールに移動されました。

PR #35971

aws-cdk-lib: .NETの名前空間修正

複数のサブモジュールで不正確な.NET名前空間が使用されていた問題が修正されました。

PR #36002

DynamoDB: AccountRootPrincipalでの循環依存の解決

AccountRootPrincipalを使用したDynamoDBテーブルへのgrant呼び出しで発生していた循環依存の問題が修正されました。

PR #35983

ECS: EC2Serviceで空のplacementStrategiesを許可

EC2ServiceでplacementStrategiesを空の配列として設定できるようになりました。これにより、デフォルトの配置戦略をオーバーライドできます。

PR #35580

まとめ

AWS CDK v2.224.0では、API GatewayのLambda権限統合オプション、Lambda Node.js 24.xランタイム、EKS 1.34サポート、SageMaker Serverless推論エンドポイント、Secrets Managerの動的参照キー取得メソッドなど、開発者の生産性を向上させる多くの新機能が追加されました。

特に、API Gatewayの権限統合オプションは、Lambda関数を複数のオペレーションで再利用する際の権限ポリシーサイズの制限問題を解決する実用的な機能です。また、SageMaker Serverless推論のサポートにより、間欠的なワークロードに対するコスト効率の高いML推論が実現可能になりました。

破壊的変更として、参照インターフェースの移動と.NETの名前空間変更がありますので、該当するコードを使用している場合は、移行が必要です。詳細は各issueを確認してください。

Alphaモジュールとして、EC2 Image BuilderのInfrastructure Configuration L2コンストラクトが追加され、Image Builderのインフラストラクチャをより高レベルなAPIで管理できるようになりました。