Skip to content

Commit

Permalink
update condition and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
godwingrs22 committed Mar 4, 2024
1 parent 2b61aa1 commit 4458a4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/aws-cdk-lib/aws-autoscaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,9 @@ property:
[Custom termination policy](https://docs.aws.amazon.com/autoscaling/ec2/userguide/lambda-custom-termination-policy.html) with lambda
can be used to determine which instances to terminate based on custom logic.
The custom termination policy can be specified using `TerminationPolicy.CUSTOM_LAMBDA_FUNCTION`. If this is
specified, you must also supply a value of lambda arn in the `terminationPolicyCustomLambdaFunctionArn` property.
specified, you must also supply a value of lambda arn in the `terminationPolicyCustomLambdaFunctionArn` property and
attach necessary [permission](https://docs.aws.amazon.com/autoscaling/ec2/userguide/lambda-custom-termination-policy.html#lambda-custom-termination-policy-create-function)
to invoke the lambda function.

If there are multiple termination policies specified,
custom termination policy with lambda `TerminationPolicy.CUSTOM_LAMBDA_FUNCTION`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1487,12 +1487,11 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements
if (props.terminationPolicies) {
props.terminationPolicies.forEach((terminationPolicy, index) => {
if (terminationPolicy === TerminationPolicy.CUSTOM_LAMBDA_FUNCTION) {
if (index != 0) {
if (index !== 0) {
throw new Error('TerminationPolicy.CUSTOM_LAMBDA_FUNCTION must be specified first in the termination policies');
}

if (!props.terminationPolicyCustomLambdaFunctionArn ||
props.terminationPolicyCustomLambdaFunctionArn.length == 0) {
if (!props.terminationPolicyCustomLambdaFunctionArn) {
throw new Error('terminationPolicyCustomLambdaFunctionArn property must be specified if the TerminationPolicy.CUSTOM_LAMBDA_FUNCTION is used');
}

Expand Down

0 comments on commit 4458a4f

Please sign in to comment.