Skip to content

Commit 2ebb409

Browse files
authored
feat(autoscaling): support custom termination policy with lambda (#29340)
### Issue # (if applicable) Closes #19750. ### Reason for this change Amazon EC2 autoscaling supports [custom termination policy](https://docs.aws.amazon.com/autoscaling/ec2/userguide/lambda-custom-termination-policy.html) using lambda to terminate instances, but it is not supported yet by the `aws-autoscaling` package. ### Description of changes This code change adds an enum `TerminationPolicy.CUSTOM_LAMBDA_FUNCTION` and an optional `terminationPolicyCustomLambdaFunctionArn` property to pass the lambda arn. The change involves the logic to check If there are multiple termination policies specified since lamba termination policy has to be [first in order](https://docs.aws.amazon.com/autoscaling/ec2/userguide/lambda-custom-termination-policy.html#lambda-custom-termination-policy-limitations). ### Description of how you validated changes Added unit tests and integration test. Created a simple CDK application with the updated constructs and verified that it synthesized and deployed correctly. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 6a69d5b commit 2ebb409

13 files changed

+2245
-1
lines changed

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-termination-policy.js.snapshot/InstanceTerminationPolicyTestDefaultTestDeployAssertD453E37E.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-termination-policy.js.snapshot/InstanceTerminationPolicyTestDefaultTestDeployAssertD453E37E.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-termination-policy.js.snapshot/aws-cdk-autoscaling-instance-termination-policy.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)