API Gateway, Can't use Stage Variables in Lambda

0

Following this documentation here. https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-stages.html

With an HTTP API with Lambda the stage variables don't seem to work. I put this into the field for the lambda ARN: arn:aws:lambda:us-east-1:xxxxx:function:${stageVariables.lambdaIssue}

And when saving I get an error that states: 1 validation error detected: Value 'arn:aws:lambda:us-east-1:xxxxxx:function:${stageVariables.lambdaIssue}' at 'functionName' 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-]+))?

View Routes (1) ANY /test

This seems to be directly contradictory to the documentation that says that should be allowed. Also, the documentation states that you should be able to use this format: arn:aws:apigateway:<region>:lambda:path/2015-03-31/functions/arn:aws:lambda:<region>:<account_id>:function:${stageVariables.<function_variable_name>}/invocations

But, using that path, aws automatically shrinks it down to the above stated arn that doesn't work.

Is this a bug with aws? Why do stage variables not work with HTTP Apis?

  • I was able to recreate the error and it looks like a bug. Open a support ticket to get further assistance.

1 Answer
0

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

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