diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-maintenance-policy.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-maintenance-policy.ts index f02a0e4dc1da7..cdae41dce4318 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-maintenance-policy.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-autoscaling/test/integ.asg-instance-maintenance-policy.ts @@ -16,8 +16,8 @@ new autoscaling.AutoScalingGroup(stack, 'ASG', { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2 }), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: 100, }); new integ.IntegTest(app, 'InstanceMaintenancePolicyTest', { diff --git a/packages/aws-cdk-lib/aws-autoscaling/README.md b/packages/aws-cdk-lib/aws-autoscaling/README.md index 04c09fcca3fb8..6c05d146d5f7f 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/README.md +++ b/packages/aws-cdk-lib/aws-autoscaling/README.md @@ -301,9 +301,9 @@ can make sure that Amazon EC2 Auto Scaling first launches a new instance and the it to be fully ready before terminating the unhealthy instance. An instance maintenance policy also helps you minimize any potential disruptions in cases where -multiple instances are replaced at the same time. You set the `maintenancePolicyMinHealthPercentage` -and the `maintenancePolicyMaxHealthPercentage` for the policy, and your Auto Scaling group can only -increase and decrease capacity within that minimum-maximum range when replacing instances. +multiple instances are replaced at the same time. You set the `instanceMaintenancePolicyMinHealthPercentage` +and the `instanceMaintenancePolicyMaxHealthPercentage` for the policy, and your Auto Scaling group +can only increase and decrease capacity within that minimum-maximum range when replacing instances. A larger range increases the number of instances that can be replaced at the same time. ```ts @@ -313,8 +313,8 @@ new autoscaling.AutoScalingGroup(this, 'ASG', { vpc, instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: 100, }); ``` diff --git a/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts b/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts index 53020763fa280..1913ce24572de 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts +++ b/packages/aws-cdk-lib/aws-autoscaling/lib/auto-scaling-group.ts @@ -692,10 +692,10 @@ export interface AutoScalingGroupProps extends CommonAutoScalingGroupProps { * It represents the maximum percentage of the group that can be in service and healthy, or pending, * to support your workload when replacing instances. * - * Value range is 0 to 100. After it's set, both `maintenancePolicyMinHealthPercentage` and - * `maintenancePolicyMaxHealthPercentage` to -1 will clear the previously set value. + * Value range is 0 to 100. After it's set, both `instanceMaintenancePolicyMinHealthPercentage` and + * `instanceMaintenancePolicyMaxHealthPercentage` to -1 will clear the previously set value. * - * Both or neither of `maintenancePolicyMinHealthPercentage` and `maintenancePolicyMaxHealthPercentage` + * Both or neither of `instanceMaintenancePolicyMinHealthPercentage` and `instanceMaintenancePolicyMaxHealthPercentage` * must be specified, and the difference between them cannot be greater than 100. A large range increases * the number of instances that can be replaced at the same time. * @@ -703,17 +703,17 @@ export interface AutoScalingGroupProps extends CommonAutoScalingGroupProps { * * @default - Do not provide percentage. */ - readonly maintenancePolicyMaxHealthPercentage?: number; + readonly instanceMaintenancePolicyMaxHealthPercentage?: number; /** * Specifies the lower threshold as a percentage of the desired capacity of the Auto Scaling group. * It represents the minimum percentage of the group to keep in service, healthy, and ready to use * to support your workload when replacing instances. * - * Value range is 0 to 100. After it's set, both `maintenancePolicyMinHealthPercentage` and - * `maintenancePolicyMaxHealthPercentage` to -1 will clear the previously set value. + * Value range is 0 to 100. After it's set, both `instanceMaintenancePolicyMinHealthPercentage` and + * `instanceMaintenancePolicyMaxHealthPercentage` to -1 will clear the previously set value. * - * Both or neither of `maintenancePolicyMinHealthPercentage` and `maintenancePolicyMaxHealthPercentage` + * Both or neither of `instanceMaintenancePolicyMinHealthPercentage` and `instanceMaintenancePolicyMaxHealthPercentage` * must be specified, and the difference between them cannot be greater than 100. A large range increases * the number of instances that can be replaced at the same time. * @@ -721,7 +721,7 @@ export interface AutoScalingGroupProps extends CommonAutoScalingGroupProps { * * @default - Do not provide percentage. */ - readonly maintenancePolicyMinHealthPercentage?: number; + readonly instanceMaintenancePolicyMinHealthPercentage?: number; } /** @@ -1464,8 +1464,8 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements defaultInstanceWarmup: props.defaultInstanceWarmup?.toSeconds(), capacityRebalance: props.capacityRebalance, instanceMaintenancePolicy: this.renderInstanceMaintenancePolicy( - props.maintenancePolicyMaxHealthPercentage, - props.maintenancePolicyMinHealthPercentage, + props.instanceMaintenancePolicyMaxHealthPercentage, + props.instanceMaintenancePolicyMinHealthPercentage, ), ...this.getLaunchSettings(launchConfig, props.launchTemplate ?? launchTemplateFromConfig, props.mixedInstancesPolicy), }; @@ -1893,16 +1893,16 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements (maxHealthPercentage !== undefined && minHealthPercentage === undefined) || (maxHealthPercentage === undefined && minHealthPercentage !== undefined) ) { - throw new Error(`Both or neither of maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage must be specified, got maintenancePolicyMinHealthPercentage: ${minHealthPercentage} and maintenancePolicyMaxHealthPercentage: ${maxHealthPercentage}`); + throw new Error(`Both or neither of instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage must be specified, got instanceMaintenancePolicyMinHealthPercentage: ${minHealthPercentage} and instanceMaintenancePolicyMaxHealthPercentage: ${maxHealthPercentage}`); } if ((maxHealthPercentage !== -1 && minHealthPercentage === -1) || (maxHealthPercentage === -1 && minHealthPercentage !== -1)) { - throw new Error(`Both maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage must be -1 to clear the previously set value, got maintenancePolicyMinHealthPercentage: ${minHealthPercentage} and maintenancePolicyMaxHealthPercentage: ${maxHealthPercentage}`); + throw new Error(`Both instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage must be -1 to clear the previously set value, got instanceMaintenancePolicyMinHealthPercentage: ${minHealthPercentage} and instanceMaintenancePolicyMaxHealthPercentage: ${maxHealthPercentage}`); } if (maxHealthPercentage !== undefined && maxHealthPercentage !== -1 && (maxHealthPercentage < 100 || maxHealthPercentage > 200)) { - throw new Error(`maintenancePolicyMaxHealthPercentage must be between 100 and 200, or -1 to clear the previously set value, got ${maxHealthPercentage}`); + throw new Error(`instanceMaintenancePolicyMaxHealthPercentage must be between 100 and 200, or -1 to clear the previously set value, got ${maxHealthPercentage}`); } if (minHealthPercentage !== undefined && minHealthPercentage !== -1 && (minHealthPercentage < 0 || minHealthPercentage > 100)) { - throw new Error(`maintenancePolicyMinHealthPercentage must be between 0 and 100, or -1 to clear the previously set value, got ${minHealthPercentage}`); + throw new Error(`instanceMaintenancePolicyMinHealthPercentage must be between 0 and 100, or -1 to clear the previously set value, got ${minHealthPercentage}`); } if ( maxHealthPercentage !== undefined @@ -1911,7 +1911,7 @@ export class AutoScalingGroup extends AutoScalingGroupBase implements && minHealthPercentage !== -1 && maxHealthPercentage - minHealthPercentage > 100 ) { - throw new Error(`The difference between maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage cannot be greater than 100, got ${maxHealthPercentage - minHealthPercentage}`); + throw new Error(`The difference between instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage cannot be greater than 100, got ${maxHealthPercentage - minHealthPercentage}`); } return { diff --git a/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts b/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts index 9c8e919fa3f77..6382ed422528c 100644 --- a/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts +++ b/packages/aws-cdk-lib/aws-autoscaling/test/auto-scaling-group.test.ts @@ -2404,7 +2404,7 @@ test('requires imdsv2 when @aws-cdk/aws-autoscaling:generateLaunchTemplateInstea }); describe('InstanceMaintenancePolicy', () => { - test('maintenancePolicyMaxHealthPercentage and maintenancePolicyMinHealthPercentage can be specified', () => { + test('instanceMaintenancePolicyMaxHealthPercentage and instanceMaintenancePolicyMinHealthPercentage can be specified', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2412,8 +2412,8 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: 100, }); // Then @@ -2425,7 +2425,7 @@ describe('InstanceMaintenancePolicy', () => { }); }); - test('maintenancePolicyMaxHealthPercentage and maintenancePolicyMinHealthPercentage can be set to -1', () => { + test('instanceMaintenancePolicyMaxHealthPercentage and instanceMaintenancePolicyMinHealthPercentage can be set to -1', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2433,8 +2433,8 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: -1, - maintenancePolicyMinHealthPercentage: -1, + instanceMaintenancePolicyMaxHealthPercentage: -1, + instanceMaintenancePolicyMinHealthPercentage: -1, }); // Then @@ -2446,7 +2446,7 @@ describe('InstanceMaintenancePolicy', () => { }); }); - test('throws if maintenancePolicyMaxHealthPercentage is greater than 200', () => { + test('throws if instanceMaintenancePolicyMaxHealthPercentage is greater than 200', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2457,13 +2457,13 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 250, - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMaxHealthPercentage: 250, + instanceMaintenancePolicyMinHealthPercentage: 100, }); - }).toThrow(/maintenancePolicyMaxHealthPercentage must be between 100 and 200, or -1 to clear the previously set value, got 250/); + }).toThrow(/instanceMaintenancePolicyMaxHealthPercentage must be between 100 and 200, or -1 to clear the previously set value, got 250/); }); - test('throws if maintenancePolicyMaxHealthPercentage is less than 100', () => { + test('throws if instanceMaintenancePolicyMaxHealthPercentage is less than 100', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2474,13 +2474,13 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 50, - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMaxHealthPercentage: 50, + instanceMaintenancePolicyMinHealthPercentage: 100, }); - }).toThrow(/maintenancePolicyMaxHealthPercentage must be between 100 and 200, or -1 to clear the previously set value, got 50/); + }).toThrow(/instanceMaintenancePolicyMaxHealthPercentage must be between 100 and 200, or -1 to clear the previously set value, got 50/); }); - test('throws if maintenancePolicyMinHealthPercentage is greater than 100', () => { + test('throws if instanceMaintenancePolicyMinHealthPercentage is greater than 100', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2491,13 +2491,13 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: 150, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: 150, }); - }).toThrow(/maintenancePolicyMinHealthPercentage must be between 0 and 100, or -1 to clear the previously set value, got 150/); + }).toThrow(/instanceMaintenancePolicyMinHealthPercentage must be between 0 and 100, or -1 to clear the previously set value, got 150/); }); - test('throws if maintenancePolicyMinHealthPercentage is less than 0', () => { + test('throws if instanceMaintenancePolicyMinHealthPercentage is less than 0', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2508,13 +2508,13 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: -100, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: -100, }); - }).toThrow(/maintenancePolicyMinHealthPercentage must be between 0 and 100, or -1 to clear the previously set value, got -100/); + }).toThrow(/instanceMaintenancePolicyMinHealthPercentage must be between 0 and 100, or -1 to clear the previously set value, got -100/); }); - test('throws if only maintenancePolicyMinHealthPercentage is set to -1', () => { + test('throws if only instanceMaintenancePolicyMinHealthPercentage is set to -1', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2525,13 +2525,13 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: -1, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: -1, }); - }).toThrow(/Both maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage must be -1 to clear the previously set value, got maintenancePolicyMinHealthPercentage: -1 and maintenancePolicyMaxHealthPercentage: 200/); + }).toThrow(/Both instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage must be -1 to clear the previously set value, got instanceMaintenancePolicyMinHealthPercentage: -1 and instanceMaintenancePolicyMaxHealthPercentage: 200/); }); - test('throws if only maintenancePolicyMaxHealthPercentage is set to -1', () => { + test('throws if only instanceMaintenancePolicyMaxHealthPercentage is set to -1', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2542,13 +2542,13 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: -1, - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMaxHealthPercentage: -1, + instanceMaintenancePolicyMinHealthPercentage: 100, }); - }).toThrow(/Both maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage must be -1 to clear the previously set value, got maintenancePolicyMinHealthPercentage: 100 and maintenancePolicyMaxHealthPercentage: -1/); + }).toThrow(/Both instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage must be -1 to clear the previously set value, got instanceMaintenancePolicyMinHealthPercentage: 100 and instanceMaintenancePolicyMaxHealthPercentage: -1/); }); - test('throws if only maintenancePolicyMinHealthPercentage is specified', () => { + test('throws if only instanceMaintenancePolicyMinHealthPercentage is specified', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2559,12 +2559,12 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMinHealthPercentage: 100, + instanceMaintenancePolicyMinHealthPercentage: 100, }); - }).toThrow(/Both or neither of maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage must be specified, got maintenancePolicyMinHealthPercentage: 100 and maintenancePolicyMaxHealthPercentage: undefined/); + }).toThrow(/Both or neither of instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage must be specified, got instanceMaintenancePolicyMinHealthPercentage: 100 and instanceMaintenancePolicyMaxHealthPercentage: undefined/); }); - test('throws if only maintenancePolicyMaxHealthPercentage is specified', () => { + test('throws if only instanceMaintenancePolicyMaxHealthPercentage is specified', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2575,12 +2575,12 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMaxHealthPercentage: 200, }); - }).toThrow(/Both or neither of maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage must be specified, got maintenancePolicyMinHealthPercentage: undefined and maintenancePolicyMaxHealthPercentage: 200/); + }).toThrow(/Both or neither of instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage must be specified, got instanceMaintenancePolicyMinHealthPercentage: undefined and instanceMaintenancePolicyMaxHealthPercentage: 200/); }); - test('throws if a difference between maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage is greater than 100', () => { + test('throws if a difference between instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage is greater than 100', () => { // GIVEN const stack = new cdk.Stack(); const vpc = mockVpc(stack); @@ -2591,10 +2591,10 @@ describe('InstanceMaintenancePolicy', () => { vpc, instanceType: new ec2.InstanceType('t2.micro'), machineImage: ec2.MachineImage.latestAmazonLinux2(), - maintenancePolicyMaxHealthPercentage: 200, - maintenancePolicyMinHealthPercentage: 0, + instanceMaintenancePolicyMaxHealthPercentage: 200, + instanceMaintenancePolicyMinHealthPercentage: 0, }); - }).toThrow(/The difference between maintenancePolicyMinHealthPercentage and maintenancePolicyMaxHealthPercentage cannot be greater than 100, got 200/); + }).toThrow(/The difference between instanceMaintenancePolicyMinHealthPercentage and instanceMaintenancePolicyMaxHealthPercentage cannot be greater than 100, got 200/); }); });