HTTP API Gateway: Specifying Different Lambda Version per Stage

1

Hello, I'm trying to create multiple stages for the same HTTP API Gateway (corresponding to Test and Production environments) and make the same Routes point to the same Lambda functions (Integrations) but different versions thereof. I'm trying to do this using CDK, but I think it's not yet supported there. However, I cannot even seem to be able to do this using the console. Any ideas?

2回答
4
承認された回答

Hello there,

you can accomplish this using stage variables. After deploying your HTTP API, go to one of the stages, edit, and go down to Stage variables.

Add a key (i.e. lambda_function_version) and as value, the version number of the lambda function you prefer.

Go to the Integration details of your API endpoint and in the Integration target section, use the ARN of the lambda function with the variable you setup previously:

arn:aws:lambda:us-east-1:xxxxxxxxxxxx:function:MyDearLambdaFunction:${stageVariables.lambda_function_version}

Repeat the process for other stages of your API.

Remember that Stage variables don't support cross-account Lambda functions.

Here's the documentation with more details. Hope this helps.

profile pictureAWS
回答済み 2年前
  • Thank you very much! Do you confirm that none of the above is (yet) doable using CDK2? Not even the part where I can set the stage variable in the Route Integration?

  • This does not work anymore. It's shown "AWS ARN for integration must contain path or action" on UI. May be a bug? Please help.

0

Sadly this does not work anymore. Whenever you put a stageVariable into integration target (if integration type is "Lambda function") it fails with "1 validation error detected: Value <arn> at 'functionName' failed to satisfy constraint: Member must satisfy regular expression pattern: <regex>"

回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ