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 Answers
4
Accepted Answer

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
answered 2 years ago
  • 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>"

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions