Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Lambda concurrency limit in CloudFormation template

I want to limit number of simultaneously running lambdas through cloudformation configuration file. I tried to search for it, but had no luck. On the documentation page there is not information about it. There are to approaches to set this limit: by console or by API. But how can I do it automatically on stack deploying?

like image 483
German Lashevich Avatar asked Dec 13 '17 15:12

German Lashevich


2 Answers

You can now set Per Function Concurrency using

ReservedConcurrentExecutions

This property allows you to set a concurrency limit to each of your Lambda functions.

Documentation for this property.

like image 110
niqui Avatar answered Oct 05 '22 01:10

niqui


I am guessing that, since this feature is relatively new (and there is no clue in the docs) there is no way to do it out-of-the-box in a cloudformation template. Your best bet if you want to use CF is a Custom Resource, where you set the concurrency via a lambda using e.g. boto3's put_function_concurrency method.

Some resources on Custom Reources: - http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html - http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/walkthrough-custom-resources-lambda-lookup-amiids.html - http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html

like image 28
DrEigelb Avatar answered Oct 05 '22 02:10

DrEigelb