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 個答案
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?

已回答 1 年前
  • 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
已回答 1 年前
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.

已回答 1 年前
  • 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-]+))?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南