Make API Gateway resource point to Lambda Alias

1

I tried to point my API Gateway resource to an alias I created for my .net Core 3.1 Lambda to be able to easily switch between versions. But no matter what ARN I specify in the integration, be it an alias (...:myalias) or specific version (...:1, ...:2), requests always end up in the most current version as if only the base ARN was specified. How can I get requests to be sent to an alias (or version)?

已提问 2 年前4693 查看次数
5 回答
0
已接受的回答

Check the answer here and see if it resolves it for you.

amoffat
已回答 2 年前
0

There are basically 3 components at play here. The first is the version. You want to create a version of your Lambda function and make sure the version construct in AWS has the specific revision of code you want deployed. You can do this in the Lambda console or with the publish-version CLI command.

Then you create the alias, and make sure the alias itself is pointed to the correct version. You can do this with the console or the create-alias command.

Once you do that, you have to make sure that the integration points to the alias. That should look like <function-name>:alias. You can do this through the API Gateway console or the create-integration CLI command.

This documentation on aliases would be helpful:

https://docs.aws.amazon.com/lambda/latest/dg/configuration-aliases.html

I'd recommend checking over these steps since you are having issues. The answer is likely in one of them.

AWS
Ted_Z
已回答 2 年前
  • Hi @Ted_Z, I'm having a similar issue here and I can confirm that it appears broken. REST gateway to a Lambda alias always goes directly to the unaliased Lambda.

0

You can use stage variable for this, there is a tutorial how to do that: https://aws.amazon.com/ru/blogs/compute/using-api-gateway-stage-variables-to-manage-lambda-functions/ (it's at the very end of the page)

已回答 2 年前
0

I think ApiGateway with Lambda integrations is bugged. I'm running into the exact same problem here. Basically, no matter if I put a version or an alias in the REST lambda integration, the calls always get forwarded to the unaliased Lambda. The CloudWatch logs prove this.

amoffat
已回答 2 年前
0

Thanks amoffat, deploying the API did the trick. I also agree that a visual indication of undeployed changes would be a good idea.

已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则