Skip to content

Commit 89d2d5c

Browse files
authored
fix(cloudformation-include): parse MinActiveInstancesPercent in AutoScalingRollingUpdate policy (#33852)
### Issue #33810 Closes #33810. ### Reason for this change When using CfnInclude to import existing CloudFormation templates, the MinActiveInstancesPercent property in AutoScaling group update policies was being silently dropped because it was missing from both the `CfnAutoScalingRollingUpdate` interface in `cfn-resource-policy.ts` and the parser in the `parseAutoScalingRollingUpdate` function in `cfn-parse.ts`. ### Description of changes This fix adds: 1. The missing `minActiveInstancesPercent` property to the `CfnAutoScalingRollingUpdate` interface in `cfn-resource-policy.ts` 2. The corresponding property parser to the `parseAutoScalingRollingUpdate` function in `cfn-parse.ts` These changes ensure that the `MinActiveInstancesPercent` property is correctly preserved when importing templates with `AutoScalingRollingUpdate` policies. ### Describe any new or updated permissions being added N/A ### Description of how you validated changes Added a comprehensive test that verifies all properties of `AutoScalingRollingUpdate` are correctly parsed, including a new test template with all properties and explicit assertions for each property. ### 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 ea1436f commit 89d2d5c

File tree

15 files changed

+532
-0
lines changed

15 files changed

+532
-0
lines changed

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/AutoScalingUpdatePolicyTestDefaultTestDeployAssert35BEDF6F.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/AutoScalingUpdatePolicyTestDefaultTestDeployAssert35BEDF6F.template.json

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/Stack.assets.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"Parameters": {
3+
"AMI": {
4+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
5+
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
6+
},
7+
"BootstrapVersion": {
8+
"Type": "AWS::SSM::Parameter::Value<String>",
9+
"Default": "/cdk-bootstrap/hnb659fds/version",
10+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
11+
}
12+
},
13+
"Resources": {
14+
"LaunchTemplate": {
15+
"Type": "AWS::EC2::LaunchTemplate",
16+
"Properties": {
17+
"LaunchTemplateData": {
18+
"ImageId": {
19+
"Ref": "AMI"
20+
},
21+
"InstanceType": "t3.micro"
22+
}
23+
}
24+
},
25+
"ASG": {
26+
"Type": "AWS::AutoScaling::AutoScalingGroup",
27+
"Properties": {
28+
"AvailabilityZones": {
29+
"Fn::GetAZs": ""
30+
},
31+
"DesiredCapacity": "2",
32+
"LaunchTemplate": {
33+
"LaunchTemplateId": {
34+
"Ref": "LaunchTemplate"
35+
},
36+
"Version": {
37+
"Fn::GetAtt": [
38+
"LaunchTemplate",
39+
"LatestVersionNumber"
40+
]
41+
}
42+
},
43+
"MaxSize": "10",
44+
"MinSize": "1"
45+
},
46+
"UpdatePolicy": {
47+
"AutoScalingRollingUpdate": {
48+
"MaxBatchSize": 2,
49+
"MinInstancesInService": 1,
50+
"MinSuccessfulInstancesPercent": 75,
51+
"MinActiveInstancesPercent": 50,
52+
"PauseTime": "PT5M",
53+
"SuspendProcesses": [
54+
"HealthCheck",
55+
"ReplaceUnhealthy"
56+
],
57+
"WaitOnResourceSignals": true
58+
}
59+
}
60+
}
61+
},
62+
"Rules": {
63+
"CheckBootstrapVersion": {
64+
"Assertions": [
65+
{
66+
"Assert": {
67+
"Fn::Not": [
68+
{
69+
"Fn::Contains": [
70+
[
71+
"1",
72+
"2",
73+
"3",
74+
"4",
75+
"5"
76+
],
77+
{
78+
"Ref": "BootstrapVersion"
79+
}
80+
]
81+
}
82+
]
83+
},
84+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
85+
}
86+
]
87+
}
88+
}
89+
}

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/cdk.out

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/integ.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/manifest.json

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/cloudformation-include/test/integ.autoscaling-update-policy.js.snapshot/tree.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as core from 'aws-cdk-lib';
2+
import * as inc from 'aws-cdk-lib/cloudformation-include';
3+
import * as integ from '@aws-cdk/integ-tests-alpha';
4+
5+
const app = new core.App();
6+
const stack = new core.Stack(app, 'Stack');
7+
8+
new inc.CfnInclude(stack, 'Stack', {
9+
templateFile: 'test-templates/autoscaling-update-policy.json',
10+
});
11+
12+
new integ.IntegTest(app, 'AutoScalingUpdatePolicyTest', {
13+
testCases: [stack],
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"Resources": {
3+
"ASG": {
4+
"Type": "AWS::AutoScaling::AutoScalingGroup",
5+
"Properties": {
6+
"MinSize": "1",
7+
"MaxSize": "10",
8+
"DesiredCapacity": "2",
9+
"AvailabilityZones": {
10+
"Fn::GetAZs": ""
11+
},
12+
"LaunchTemplate": {
13+
"LaunchTemplateId": { "Ref": "LaunchTemplate" },
14+
"Version": { "Fn::GetAtt": ["LaunchTemplate", "LatestVersionNumber"] }
15+
}
16+
},
17+
"UpdatePolicy": {
18+
"AutoScalingRollingUpdate": {
19+
"MaxBatchSize": 2,
20+
"MinInstancesInService": 1,
21+
"MinSuccessfulInstancesPercent": 75,
22+
"MinActiveInstancesPercent": 50,
23+
"PauseTime": "PT5M",
24+
"SuspendProcesses": ["HealthCheck", "ReplaceUnhealthy"],
25+
"WaitOnResourceSignals": true
26+
}
27+
}
28+
},
29+
"LaunchTemplate": {
30+
"Type": "AWS::EC2::LaunchTemplate",
31+
"Properties": {
32+
"LaunchTemplateData": {
33+
"ImageId": { "Ref": "AMI" },
34+
"InstanceType": "t3.micro"
35+
}
36+
}
37+
}
38+
},
39+
"Parameters": {
40+
"AMI": {
41+
"Type": "AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>",
42+
"Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)