Lambda provisioned concurrency for $LATEST, or, updating API gateway to refer to version

1

Dear Experts,

I have API gateway and Lambda working happily, without using any versions or aliases. I'd now like to enable provisioned concurrency.

It seems that I cannot configure provisioned concurrency for $LATEST - is that correct? (Can I maybe enter "$LATEST" in the Alias field in the provisioned concurrency set up box?)

Assuming that I cannot do that, what's the best, simplest way to move forward? Let's say that I publish a new version now and enable provisioned concurrency for that version. Until I next upload code, $LATEST == this version - so do invocations from API gateway use the provisioned concurrency?

My guess is no, and that I need to update my API gateway configuration to refer to either this published version of the function, or to refer to a named alias which I need to create and make refer to this version.

I do not find the API Gateway console particularly clear. It has an "Integrations" page which refers to my lambda function by name, but there doesn't seem to be a field on that page where I can set the version or alias of the function. Similarly if I create a new integration I can choose the function by name, but not select a version or alias. Do I somehow configure this from the Lambda end?

Any advice would be much appreciated.

Thanks, Phil.

已提问 2 年前5047 查看次数
6 回答
0

We're having the same issue. Lodging a support ticket, but following here as well.

已回答 2 年前
0

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.

Zach
已回答 2 年前
0

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.

profile pictureAWS
专家
Uri
已回答 2 年前
0

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?

已回答 2 年前
0

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.

已回答 2 年前
0

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.

已回答 2 年前

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

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

回答问题的准则