Created
December 11, 2019 04:07
-
-
Save congdang-agilityio/a7b9aaa19745b5b038b212fbcf7cf3ea to your computer and use it in GitHub Desktop.
CloudFormation template for setting up Lambda Provisioned Concurrency and AutoScaling by using Utilization metric
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyFunction: | |
| Type: AWS::Lambda::Function | |
| Properties: | |
| FunctionName: hello | |
| Code: | |
| S3Bucket: lambda-repos | |
| S3Key: hello.zip | |
| Handler: lambda.handler | |
| Environment: | |
| Variables: | |
| NODE_ENV: development | |
| MemorySize: 256 | |
| TracingConfig: | |
| Mode: Active | |
| Role: !Ref LambdaExecutionRole | |
| Runtime: nodejs10.x | |
| Timeout: 600 | |
| LambdaVersion: | |
| Type: AWS::Lambda::Version | |
| Properties: | |
| FunctionName: !Ref MyFunction | |
| ProvisionedConcurrencyConfig: | |
| ProvisionedConcurrentExecutions: 1 # Start with 1 | |
| ScalableTarget: | |
| Type: AWS::ApplicationAutoScaling::ScalableTarget | |
| Properties: | |
| MaxCapacity: 100 | |
| MinCapacity: 1 | |
| ResourceId: !Join | |
| - ":" | |
| - - function | |
| - !Ref MyFunction | |
| - !GetAtt LambdaVersion.Version | |
| RoleARN: !Ref LambdaScalingRole | |
| ScalableDimension: lambda:function:ProvisionedConcurrency | |
| ServiceNamespace: lambda | |
| TargetTrackingScalingPolicy: | |
| Type: AWS::ApplicationAutoScaling::ScalingPolicy | |
| Properties: | |
| PolicyName: utilization | |
| PolicyType: TargetTrackingScaling | |
| ScalingTargetId: !Ref ScalableTarget | |
| TargetTrackingScalingPolicyConfiguration: | |
| TargetValue: 0.70 # Any value between 0 and 1 can be used here | |
| PredefinedMetricSpecification: | |
| PredefinedMetricType: LambdaProvisionedConcurrencyUtilization |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Comment here if you wanted to ask something related to this gist. Give a star if you think it's helpful. Thanks!