Back to Releases
v2.195.0 2025年5月7日

AWS CDK v2.195.0 リリース解説

API Gateway REST APIでデュアルスタックIPアドレスタイプのサポート、IoTデバイス証明書の経過日数監査機能、Location Service API Keyコンストラクトの追加など、複数の新機能とバグ修正が含まれるリリースです。

apigatewaycodepipelineroute53s3iotlocation

概要

AWS CDK v2.195.0では、API Gateway REST APIでデュアルスタックIPアドレスタイプがサポートされ、IPv4とIPv6の両方に対応できるようになりました。また、IoT Device Defenderでデバイス証明書の経過日数チェックが追加され、Location ServiceのAPI KeyをL2コンストラクトで管理できるようになりました。

新機能

API Gateway: デュアルスタックREST APIのサポート

API Gateway REST APIで、エンドポイントのIPアドレスタイプを指定できるようになりました。これにより、IPv4のみ、またはIPv4とIPv6のデュアルスタック構成を選択できます。

実装詳細:

  • EndpointConfigurationipAddressTypeプロパティを追加
  • IpAddressType列挙型でIPV4DUAL_STACKをサポート
  • プライベートAPIではDUAL_STACKのみ利用可能(IPV4指定時はエラー)

コード例:

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

// デュアルスタック(IPv4 + IPv6)のREST API
const api = new apigateway.RestApi(this, 'MyApi', {
  restApiName: 'my-dualstack-api',
  endpointConfiguration: {
    types: [apigateway.EndpointType.REGIONAL],
    // デュアルスタックIPアドレスタイプを指定(IPv4とIPv6の両方をサポート)
    ipAddressType: apigateway.IpAddressType.DUAL_STACK,
  },
});

// IPv4のみのREST API
const ipv4OnlyApi = new apigateway.RestApi(this, 'MyIpv4OnlyApi', {
  restApiName: 'my-ipv4-api',
  endpointConfiguration: {
    types: [apigateway.EndpointType.REGIONAL],
    // IPv4のみを指定
    ipAddressType: apigateway.IpAddressType.IPV4,  // デフォルト値
  },
});

// プライベートAPIの場合はデュアルスタックのみ
const privateApi = new apigateway.RestApi(this, 'MyPrivateApi', {
  restApiName: 'my-private-api',
  endpointConfiguration: {
    types: [apigateway.EndpointType.PRIVATE],
    vpcEndpoints: [vpcEndpoint],
    // プライベートAPIはデュアルスタックのみサポート
    ipAddressType: apigateway.IpAddressType.DUAL_STACK,
  },
});

参考:

Go言語向けにapp-staging-synthesizer-alphaパッケージを公開

Go言語でAWS CDKを使用する際に、app-staging-synthesizer-alphaパッケージが利用可能になりました。これにより、Go開発者もアプリケーションステージング合成機能を使用できるようになります。

CloudFormation L1リソース定義の更新

最新のCloudFormationリソース定義が反映され、新しいサービスやプロパティがL1コンストラクトで利用可能になりました。

Alphaモジュール

IoT: デバイス証明書の経過日数監査機能

IoT Device Defenderの監査設定に、デバイス証明書の経過日数チェック機能が追加されました。これにより、古い証明書を検出して、セキュリティリスクを低減できます。

⚠️ 破壊的変更: デフォルトでdeviceCertificateAgeCheckが自動的に有効化されます。既存のスタックでは、この監査チェックが追加されます。

実装詳細:

  • CheckConfigurationdeviceCertificateAgeCheckプロパティを追加(デフォルト: true
  • CheckConfigurationdeviceCertificateAgeCheckDurationプロパティを追加(しきい値の日数を指定)
  • デフォルトのしきい値は365日
  • 有効な範囲: 30日(最小)〜3652日(10年、最大)

コード例:

import * as iot from '@aws-cdk/aws-iot-alpha';
import * as sns from 'aws-cdk-lib/aws-sns';
import { Duration } from 'aws-cdk-lib';

// 監査結果を受信するSNSトピック
const topic = new sns.Topic(this, 'AuditTopic');

// IoT監査設定
const auditConfig = new iot.AuditConfiguration(this, 'AuditConfig', {
  targetTopic: topic,
  checkConfiguration: {
    // デバイス証明書の経過日数チェックを有効化(デフォルト: true)
    deviceCertificateAgeCheck: true,

    // しきい値を180日に設定(デフォルト: 365日)
    // 証明書が180日以上使用されている場合に監査で検出される
    deviceCertificateAgeCheckDuration: Duration.days(180),

    // その他の監査チェックも設定可能
    deviceCertificateExpiringCheck: true,  // 有効期限切れチェック(デフォルト: true)
    deviceCertificateKeyQualityCheck: true,  // 証明書キー品質チェック(デフォルト: true)
  },
});

// 明示的に無効化する場合
const auditConfigDisabled = new iot.AuditConfiguration(this, 'AuditConfigDisabled', {
  targetTopic: topic,
  checkConfiguration: {
    // 経過日数チェックを無効化
    deviceCertificateAgeCheck: false,
    // 無効化した場合、durationは指定できない(エラーになる)
  },
});

移行ガイド:

既存のスタックをアップデートする際、デフォルトでdeviceCertificateAgeCheckが有効化されます。この変更を避けたい場合は、明示的にfalseを設定してください:

const auditConfig = new iot.AuditConfiguration(this, 'AuditConfig', {
  targetTopic: topic,
  checkConfiguration: {
    // 既存の動作を維持する場合は明示的に無効化
    deviceCertificateAgeCheck: false,
  },
});

参考:

Location Service: API KeyのL2コンストラクト追加

Amazon Location ServiceのAPI Keyを管理するL2コンストラクトが追加されました。これにより、Maps、Places、Routesの各サービスに対するアクセス許可を細かく制御できます。

実装詳細:

  • 新しいApiKeyコンストラクトを追加
  • 有効期限の設定(expireTimeまたはnoExpiry)をサポート
  • Maps、Places、Routesに対する許可アクション(AllowMapsAction, AllowPlacesAction, AllowRoutesAction)を指定可能
  • APIキーの強制削除(forceDelete)と強制更新(forceUpdate)に対応

コード例:

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

// 基本的なAPI Key(有効期限なし)
const apiKey = new location.ApiKey(this, 'MyApiKey', {
  apiKeyName: 'my-location-api-key',
  description: 'API Key for location services',
  // 有効期限なし
  noExpiry: true,
});

// 有効期限付きAPI Key
const expiringApiKey = new location.ApiKey(this, 'ExpiringApiKey', {
  apiKeyName: 'expiring-api-key',
  description: 'API Key that expires in 90 days',
  // 90日後に有効期限切れ
  expireTime: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000),
});

// 特定のアクションを許可するAPI Key
const restrictedApiKey = new location.ApiKey(this, 'RestrictedApiKey', {
  apiKeyName: 'restricted-api-key',
  noExpiry: true,
  // Maps: 地図タイルの取得のみ許可
  allowMapsActions: [
    location.AllowMapsAction.GET_TILE,  // 地図タイル取得を許可
  ],
  // Places: ジオコーディングと逆ジオコーディングのみ許可
  allowPlacesActions: [
    location.AllowPlacesAction.GEOCODE,  // 住所→座標変換を許可
    location.AllowPlacesAction.REVERSE_GEOCODE,  // 座標→住所変換を許可
  ],
  // Routes: ルート計算のみ許可
  allowRoutesActions: [
    location.AllowRoutesAction.CALCULATE_ROUTES,  // ルート計算を許可
  ],
});

// すべてのアクションを許可するAPI Key
const fullAccessApiKey = new location.ApiKey(this, 'FullAccessApiKey', {
  apiKeyName: 'full-access-api-key',
  noExpiry: true,
  // Maps: すべてのアクションを許可
  allowMapsActions: [location.AllowMapsAction.ANY],
  // Places: すべてのアクションを許可
  allowPlacesActions: [location.AllowPlacesAction.ANY],
  // Routes: すべてのアクションを許可
  allowRoutesActions: [location.AllowRoutesAction.ANY],
});

// 既存のAPI Keyをインポート
const importedApiKey = location.ApiKey.fromApiKeyName(
  this,
  'ImportedApiKey',
  'existing-api-key-name'
);

// ARNからインポート
const importedByArn = location.ApiKey.fromApiKeyArn(
  this,
  'ImportedByArn',
  'arn:aws:geo:us-east-1:123456789012:api-key/my-api-key'
);

// API Key名とARNを参照
console.log('API Key Name:', apiKey.apiKeyName);
console.log('API Key ARN:', apiKey.apiKeyArn);
console.log('Created at:', apiKey.apiKeyCreateTime);
console.log('Updated at:', apiKey.apiKeyUpdateTime);

許可アクションの一覧:

Maps(地図サービス):

  • GET_STATIC_MAP: 静的地図画像の取得
  • GET_TILE: 地図タイルの取得(レンダリング用)
  • ANY: すべてのMapsアクションを許可

Places(場所検索サービス):

  • AUTOCOMPLETE: 検索テキストのオートコンプリート
  • GEOCODE: 住所から地理座標への変換
  • GET_PLACE: 場所の詳細情報取得
  • REVERSE_GEOCODE: 地理座標から住所への変換
  • SEARCH_NEARBY: 座標周辺のカテゴリベース検索
  • SEARCH_TEXT: フリーテキストベースの場所検索
  • SUGGEST: 不完全なクエリに基づく提案
  • ANY: すべてのPlacesアクションを許可

Routes(ルート検索サービス):

  • CALCULATE_ISOLINES: 等時間線の計算
  • CALCULATE_ROUTES: 地点間のルート計算
  • CALCULATE_ROUTE_MATRIX: マトリクスルーティング
  • OPTIMIZE_WAYPOINTS: ウェイポイントの最適な順序計算
  • SNAP_TO_ROADS: GPSポイントを道路にスナップ
  • ANY: すべてのRoutesアクションを許可

参考:

Amplify: カスタムルール追加のサンプルコード修正

Amplifyのドキュメントで、カスタムルール追加のサンプルコードが誤っていた問題を修正しました。

バグ修正

CodePipeline: pullRequestFilterpushFilterの両方を指定可能に

以前はpullRequestFilterpushFilterを同時に指定できませんでしたが、両方を同時に設定できるようになりました。これにより、プルリクエストとプッシュの両方をトリガーとして設定できます。

コード例:

import * as codepipeline from 'aws-cdk-lib/aws-codepipeline';
import * as codepipeline_actions from 'aws-cdk-lib/aws-codepipeline-actions';

const sourceAction = new codepipeline_actions.CodeStarConnectionsSourceAction({
  actionName: 'GitHub_Source',
  owner: 'my-org',
  repo: 'my-repo',
  connectionArn: 'arn:aws:codestar-connections:...',
  output: sourceOutput,
  // プルリクエストとプッシュの両方をトリガーに設定可能
  triggerOnPush: true,
  // プルリクエストフィルター
  pullRequestFilter: {
    branchesIncludes: ['main', 'develop'],
    events: ['OPEN', 'UPDATED'],
  },
  // プッシュフィルター
  pushFilter: {
    branchesIncludes: ['main'],
  },
});

Route53: Elastic BeanstalkターゲットでhostedZoneIdの指定をサポート

Route53のAliasターゲットとしてElastic Beanstalkを使用する際に、hostedZoneIdを明示的に指定できるようになりました。これにより、トークン化されたエンドポイントやカスタムリージョンに対応できます。

デフォルト値はスタックのリージョンまたはendpointUrlから導出されます。

コード例:

import * as route53 from 'aws-cdk-lib/aws-route53';
import * as targets from 'aws-cdk-lib/aws-route53-targets';

// Elastic Beanstalk環境のエンドポイント
const beanstalkEndpoint = 'my-env.us-east-1.elasticbeanstalk.com';

// hostedZoneIdを明示的に指定
new route53.ARecord(this, 'AliasRecord', {
  zone: hostedZone,
  recordName: 'app.example.com',
  target: route53.RecordTarget.fromAlias(
    new targets.ElasticBeanstalkEnvironmentEndpointTarget(beanstalkEndpoint, {
      // Elastic BeanstalkのホストゾーンIDを明示的に指定
      hostedZoneId: 'Z117KPS5GTRQ2G',  // us-east-1のElastic Beanstalk Hosted Zone ID
    })
  ),
});

S3: KMS暗号化されたSNSトピックへの通知でキーポリシーを自動追加

S3バケットから、KMSキーで暗号化されたSNSトピックへの通知を設定する際、S3を信頼するキーポリシーが自動的に追加されるようになりました。

この機能はフィーチャーフラグ(@aws-cdk/aws-s3:notifications-enable-kms-key-policy)で制御されます。

コード例:

import * as s3 from 'aws-cdk-lib/aws-s3';
import * as s3n from 'aws-cdk-lib/aws-s3-notifications';
import * as sns from 'aws-cdk-lib/aws-sns';
import * as kms from 'aws-cdk-lib/aws-kms';

// KMSキーで暗号化されたSNSトピック
const kmsKey = new kms.Key(this, 'Key');
const topic = new sns.Topic(this, 'Topic', {
  masterKey: kmsKey,
});

const bucket = new s3.Bucket(this, 'Bucket');

// S3通知を設定すると、KMSキーポリシーが自動的に追加される
// (フィーチャーフラグ有効時)
bucket.addEventNotification(
  s3.EventType.OBJECT_CREATED,
  new s3n.SnsDestination(topic)
);

cdk.json設定:

{
  "context": {
    "@aws-cdk/aws-s3:notifications-enable-kms-key-policy": true
  }
}

Reverts(取り消し)

以下の変更が取り消されました:

  1. L2コンストラクトのプロパティインジェクション機能 (#34371)

    • リリースプロセス中にL2コンストラクトをプロパティインジェクション可能にする変更を取り消し
  2. 122個のコンストラクトへのプロパティインジェクション (#34370)

    • 122個のコンストラクトへのプロパティインジェクション機能の実装を取り消し

まとめ

AWS CDK v2.195.0では、API GatewayのデュアルスタックIPアドレス対応、IoTデバイス証明書の経過日数監査、Location Service API Keyのマネージドコンストラクトなど、セキュリティとネットワーク機能が強化されました。

特にAlphaモジュールでは、IoTのデバイス証明書監査がデフォルトで有効化される破壊的変更が含まれるため、既存スタックをアップデートする際は注意が必要です。また、Location ServiceのAPI Key管理が大幅に簡素化され、きめ細かいアクセス制御が可能になりました。

バグ修正では、CodePipelineのフィルター設定の柔軟性が向上し、Route53とS3の統合がより堅牢になりました。