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>"

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인