- 最新
- 投票最多
- 评论最多
We ran into a similar issue with a hitting an API Gateway WebSocket API, where the requests were being routed to a Lambda that had an established Alias with provisioned concurrency setup. After deployment, we realized none of the requests were being handled by the provisioned lambda instances.
As you suspect, the issue was that our WebSocketApi routes were configured to point directly at the ARN of the Lambda we created, and not the ARN of the alias (or version), which is referred to as the "qualified" ARN.
To correct this in the Console, in the Integration settings, where it specifies the name of the Lambda you're targeting, you can append the version or alias to the function name using a colon.
For example, with a function named lambda_worker
and an alias named current
you would specify:
lambda_worker:current
You can then setup provisioned concurrency on that lambda alias and the routed requests should be handled by your provisioned instances.
In the console you can select from the list of functions and that will actually refer to the $LATEST version. Alternatively, you could just put the full function ARN, including the alias (e.g., arn:aws:lambda:REGION:ACCOUNT:function:FUNCTION-NAME:ALIAS-NAME
) and that will work as well.
Saying that, I would recommend not using the console but rather use infrastructure as code tools such as SAM, CloudFormation, CDK, Terraform, etc.
Thanks for the answers everyone. I've just noticed that in the "create alias" form, I appear to be able to create an alias that refers to $LATEST. If I do this, will I be able to configure provisioned concurrency for that alias? Will it continue to refer to the new $LATEST when I upload a new version?
Answering that last point - I see that there is a note "Can't assign an alias with provisioned concurrency to $LATEST" if you try to do that.
To summarise:
- It's correct that you can't have provisioned concurrency for $LATEST.
- You need to publish new versions after each update.
- You can create an alias, which you need to update to refer to the newest published version each time.
- The alias can have provisioned concurrency.
- In API Gateway, you can paste the ARN of the alias in the integration target. (You may also be able to type lambda-name:alias, but I've not tried that.)
Thanks for the comments everyone.
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 3 年前