errors using stage variables in API Gateway

1

for a HTTP API, I added the stage variables say: alias, and the value is qa I added the stageVariable in the integration, however, I got the error Enter image description here

my question is: is there a way to use the stage variables in the implementation part? Or it is not allowed? this is the doc. Enter image description here

3 Answers
1

1st you should mask your AWS account number from the screen shot.

about your issue. looks like it is complaining about invalid function name.. you are trying to use lambda function name as order:${variable} are you sure about this?

answered a year ago
  • thanks a lot. updated my question. I was trying to refer to a specific version of a lambda function. say if the alias is: qa, then there is a unique ARN for this versioned lambda

1

For future people trying to fix this.

This is 100% a bug on AWS's side. HOWEVER, it's not the actual error that AWS is telling you. Even though it says that the route couldn't be updated and there was the above error. The route does in fact update and it does work correctly. So, I was stopped because I didn't go any further after the error? I mean, why would I? But if you do continue on the process and give all your lambdas the correct permissions. Then the stage variable does work. Despite AWS saying it failed to save.

arith
answered a year ago
0

yes stage variable should work. pls refer here https://aws.amazon.com/blogs/compute/using-api-gateway-stage-variables-to-manage-lambda-functions/ You might not able to test it on AWS API gateway test console but with actual stage deployed url your api will work appropriately.

answered a year ago
  • thanks. but if I added the stageVariables like my first screenshot, error will be thrown as well, indicates failed to update the routes

    failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-]+)(:($LATEST|[a-zA-Z0-9-]+))?

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