Back to Releases
v2.234.1 2026年1月9日

AWS CDK v2.234.1 リリース解説

API Gateway V2のHttpApi.fromHttpApiAttributes()でapiEndpointが取得できないバグを修正するパッチリリースです。

apigatewayv2

概要

AWS CDK v2.234.1は、API Gateway V2モジュールの重要なバグを修正するパッチリリースです。v2.234.0で導入されたインターフェースのリファクタリング(#36378)により、HttpApi.fromHttpApiAttributes()でインポートしたHTTP APIのapiEndpointプロパティにアクセスしようとするとRuntimeErrorが発生する問題がありましたが、この変更をリバートすることで修正されました。

バグ修正

apigatewayv2: RuntimeError: apiEndpoint is not configured on the imported HttpApiの修正

(#36623)

問題の詳細:

v2.234.0で行われたAPI Gateway V2モジュールのインターフェースリファクタリング(#36378)により、既存のAPIをインポートする際に問題が発生していました。具体的には、HttpApi.fromHttpApiAttributes()メソッドを使用してインポートしたHTTP APIのapiEndpointプロパティにアクセスしようとすると、以下のようなランタイムエラーが発生していました:

RuntimeError: apiEndpoint is not configured on the imported HttpApi

問題が発生するコード例:

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

// 既存のHTTP APIをインポート
const importedApi = apigatewayv2.HttpApi.fromHttpApiAttributes(this, 'ImportedApi', {
  httpApiId: 'existing-api-id',
  apiEndpoint: 'https://abc123.execute-api.ap-northeast-1.amazonaws.com',
});

// v2.234.0では以下の行でRuntimeErrorが発生
const endpoint = importedApi.apiEndpoint;  // エラー!

修正内容:

この問題を解決するため、#36378で行われたインターフェースリファクタリングを完全にリバートしました。これにより、以下のファイルが元の実装に戻されました:

  • aws-apigatewayv2/lib/http/api.ts
  • aws-apigatewayv2/lib/http/stage.ts
  • aws-apigatewayv2/lib/websocket/api.ts
  • その他、関連する多数のファイル

修正後の正しい使い方:

v2.234.1では、従来通りインポートしたAPIのapiEndpointプロパティに正しくアクセスできます:

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

// 既存のHTTP APIをインポート
const importedApi = apigatewayv2.HttpApi.fromHttpApiAttributes(this, 'ImportedApi', {
  httpApiId: 'abc123xyz',                                              // 既存のAPI ID
  apiEndpoint: 'https://abc123xyz.execute-api.ap-northeast-1.amazonaws.com',  // APIエンドポイント
});

// apiEndpointに正しくアクセス可能(v2.234.1で修正)
console.log(`API Endpoint: ${importedApi.apiEndpoint}`);

// インポートしたAPIにルートを追加
const handler = new lambda.Function(this, 'Handler', {
  runtime: lambda.Runtime.NODEJS_20_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda'),
});

importedApi.addRoutes({
  path: '/items',
  methods: [apigatewayv2.HttpMethod.GET],
  integration: new HttpLambdaIntegration('LambdaIntegration', handler),
});

影響を受けるユーザー:

v2.234.0を使用していて、以下のような操作を行っている場合、この問題の影響を受けていた可能性があります:

  • HttpApi.fromHttpApiAttributes()でHTTP APIをインポートしている
  • インポートしたAPIのapiEndpointプロパティを参照している
  • API Gateway V2のWebSocket APIを同様の方法でインポートしている

推奨アクション:

v2.234.0を使用していて上記のエラーが発生している場合は、v2.234.1にアップグレードしてください:

npm install aws-cdk-lib@2.234.1

Alpha モジュール

このリリースには、Alphaモジュール向けの変更は含まれていません(v2.234.1-alpha.0)。

まとめ

AWS CDK v2.234.1は、API Gateway V2モジュールの重要なバグを修正するパッチリリースです。v2.234.0で導入されたインターフェースのリファクタリングにより、HttpApi.fromHttpApiAttributes()でインポートしたAPIのapiEndpointプロパティにアクセスできなくなる問題が発生していましたが、この変更をリバートすることで問題が解決されました。

API Gateway V2のfromHttpApiAttributes()fromWebSocketApiAttributes()を使用している場合は、v2.234.1へのアップグレードを推奨します。