limit unreserved concurrency of a lambda function

Viewed 982

I don't find the AWS documentation very clear on this, but it seems like there is no way to limit the unreserved concurrency of an AWS Lambda function. Instead it requires a reserved concurrency, which has to be provisioned and therefor comes at an additional costs.

Is that correct?

And even when I try to add a concurrency configuration it fails to apply it for the "$LATEST" version. Why is that?

resource "aws_lambda_provisioned_concurrency_config" "deliver" {
  function_name                     = aws_lambda_function.deliver.function_name
  qualifier                         = aws_lambda_function.deliver.version
  provisioned_concurrent_executions = 1
}
2 Answers

Reserved concurrency doesn't have to be provisioned. If you only set reserved_concurrent_executions on the lambda_function resource, instead of creating a aws_lambda_provisioned_concurrency_config resource, then it will simply limit the amount of concurrency for the function. This will also guarantee that the other functions in your account don't use up your Lambda concurrency account limits in a way that prevent this function from executing.

The reserved_concurrent_executions property controls the concurrency limit feature.

The aws_lambda_provisioned_concurrency_config resource controls the provisioned concurrency feature.

I believe Reserved Concurrency will do what you're looking for. You can also use autoscaling to control the level of provisioned concurrency (and perhaps even Reserved Concurrency?) based on utilisation.

But you can't allocate provisioned concurrency on an alias that points to the unpublished version ($LATEST).

Related