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)?

preguntada hace 2 años4693 visualizaciones
5 Respuestas
0
Respuesta aceptada

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

amoffat
respondido hace 2 años
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
respondido hace 2 años
  • 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)

respondido hace 2 años
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
respondido hace 2 años
0

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

respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas