Skip to content

Commit

Permalink
feat(client-auto-scaling): Auto Scaling groups now support the abilit…
Browse files Browse the repository at this point in the history
…y to strictly balance instances across Availability Zones by configuring the AvailabilityZoneDistribution parameter. If balanced-only is configured for a group, launches will always be attempted in the under scaled Availability Zone even if it is unhealthy.
  • Loading branch information
awstools committed Nov 7, 2024
1 parent 6607253 commit 3589a0f
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ export interface CreateAutoScalingGroupCommandOutput extends __MetadataBearer {}
* MinHealthyPercentage: Number("int"),
* MaxHealthyPercentage: Number("int"),
* },
* AvailabilityZoneDistribution: { // AvailabilityZoneDistribution
* CapacityDistributionStrategy: "balanced-only" || "balanced-best-effort",
* },
* };
* const command = new CreateAutoScalingGroupCommand(input);
* const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export interface DescribeAutoScalingGroupsCommandOutput extends AutoScalingGroup
* // MinHealthyPercentage: Number("int"),
* // MaxHealthyPercentage: Number("int"),
* // },
* // AvailabilityZoneDistribution: { // AvailabilityZoneDistribution
* // CapacityDistributionStrategy: "balanced-only" || "balanced-best-effort",
* // },
* // },
* // ],
* // NextToken: "STRING_VALUE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ export interface UpdateAutoScalingGroupCommandOutput extends __MetadataBearer {}
* MinHealthyPercentage: Number("int"),
* MaxHealthyPercentage: Number("int"),
* },
* AvailabilityZoneDistribution: { // AvailabilityZoneDistribution
* CapacityDistributionStrategy: "balanced-only" || "balanced-best-effort",
* },
* };
* const command = new UpdateAutoScalingGroupCommand(input);
* const response = await client.send(command);
Expand Down
62 changes: 62 additions & 0 deletions clients/client-auto-scaling/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,46 @@ export interface CompleteLifecycleActionType {
InstanceId?: string;
}

/**
* @public
* @enum
*/
export const CapacityDistributionStrategy = {
BALANCED_BEST_EFFORT: "balanced-best-effort",
BALANCED_ONLY: "balanced-only",
} as const;

/**
* @public
*/
export type CapacityDistributionStrategy =
(typeof CapacityDistributionStrategy)[keyof typeof CapacityDistributionStrategy];

/**
* <p>
* Describes an Availability Zone distribution.
* </p>
* @public
*/
export interface AvailabilityZoneDistribution {
/**
* <p>
* If launches fail in an Availability Zone, the following strategies are available. The default is <code>balanced-best-effort</code>. </p>
* <ul>
* <li>
* <p>
* <code>balanced-only</code> - If launches fail in an Availability Zone, Auto Scaling will continue to attempt to launch in the unhealthy zone to preserve a balanced distribution.</p>
* </li>
* <li>
* <p>
* <code>balanced-best-effort</code> - If launches fail in an Availability Zone, Auto Scaling will attempt to launch in another healthy Availability Zone instead.</p>
* </li>
* </ul>
* @public
*/
CapacityDistributionStrategy?: CapacityDistributionStrategy;
}

/**
* <p>Describes an instance maintenance policy.</p>
* <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-maintenance-policy.html">Set instance maintenance policy</a> in the
Expand Down Expand Up @@ -2103,6 +2143,12 @@ export interface CreateAutoScalingGroupType {
* @public
*/
InstanceMaintenancePolicy?: InstanceMaintenancePolicy;

/**
* <p>The instance capacity distribution across Availability Zones.</p>
* @public
*/
AvailabilityZoneDistribution?: AvailabilityZoneDistribution;
}

/**
Expand Down Expand Up @@ -3481,6 +3527,14 @@ export interface AutoScalingGroup {
* @public
*/
InstanceMaintenancePolicy?: InstanceMaintenancePolicy;

/**
* <p>
* The instance capacity distribution across Availability Zones.
* </p>
* @public
*/
AvailabilityZoneDistribution?: AvailabilityZoneDistribution;
}

/**
Expand Down Expand Up @@ -8241,4 +8295,12 @@ export interface UpdateAutoScalingGroupType {
* @public
*/
InstanceMaintenancePolicy?: InstanceMaintenancePolicy;

/**
* <p>
* The instance capacity distribution across Availability Zones.
* </p>
* @public
*/
AvailabilityZoneDistribution?: AvailabilityZoneDistribution;
}
42 changes: 42 additions & 0 deletions clients/client-auto-scaling/src/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ import {
AutoScalingGroupsType,
AutoScalingInstanceDetails,
AutoScalingInstancesType,
AvailabilityZoneDistribution,
BaselineEbsBandwidthMbpsRequest,
BatchDeleteScheduledActionAnswer,
BatchDeleteScheduledActionType,
Expand Down Expand Up @@ -3248,6 +3249,17 @@ const se_AutoScalingNotificationTypes = (input: string[], context: __SerdeContex
return entries;
};

/**
* serializeAws_queryAvailabilityZoneDistribution
*/
const se_AvailabilityZoneDistribution = (input: AvailabilityZoneDistribution, context: __SerdeContext): any => {
const entries: any = {};
if (input[_CDS] != null) {
entries[_CDS] = input[_CDS];
}
return entries;
};

/**
* serializeAws_queryAvailabilityZones
*/
Expand Down Expand Up @@ -3598,6 +3610,13 @@ const se_CreateAutoScalingGroupType = (input: CreateAutoScalingGroupType, contex
entries[loc] = value;
});
}
if (input[_AZD] != null) {
const memberEntries = se_AvailabilityZoneDistribution(input[_AZD], context);
Object.entries(memberEntries).forEach(([key, value]) => {
const loc = `AvailabilityZoneDistribution.${key}`;
entries[loc] = value;
});
}
return entries;
};

Expand Down Expand Up @@ -6359,6 +6378,13 @@ const se_UpdateAutoScalingGroupType = (input: UpdateAutoScalingGroupType, contex
entries[loc] = value;
});
}
if (input[_AZD] != null) {
const memberEntries = se_AvailabilityZoneDistribution(input[_AZD], context);
Object.entries(memberEntries).forEach(([key, value]) => {
const loc = `AvailabilityZoneDistribution.${key}`;
entries[loc] = value;
});
}
return entries;
};

Expand Down Expand Up @@ -6800,6 +6826,9 @@ const de_AutoScalingGroup = (output: any, context: __SerdeContext): AutoScalingG
if (output[_IMP] != null) {
contents[_IMP] = de_InstanceMaintenancePolicy(output[_IMP], context);
}
if (output[_AZD] != null) {
contents[_AZD] = de_AvailabilityZoneDistribution(output[_AZD], context);
}
return contents;
};

Expand Down Expand Up @@ -6906,6 +6935,17 @@ const de_AutoScalingNotificationTypes = (output: any, context: __SerdeContext):
});
};

/**
* deserializeAws_queryAvailabilityZoneDistribution
*/
const de_AvailabilityZoneDistribution = (output: any, context: __SerdeContext): AvailabilityZoneDistribution => {
const contents: any = {};
if (output[_CDS] != null) {
contents[_CDS] = __expectString(output[_CDS]);
}
return contents;
};

/**
* deserializeAws_queryAvailabilityZones
*/
Expand Down Expand Up @@ -9425,6 +9465,7 @@ const _ATS = "AttachTrafficSources";
const _ATd = "AdjustmentType";
const _ATdj = "AdjustmentTypes";
const _AZ = "AvailabilityZones";
const _AZD = "AvailabilityZoneDistribution";
const _AZv = "AvailabilityZone";
const _Ac = "Activities";
const _Act = "Activity";
Expand All @@ -9441,6 +9482,7 @@ const _C = "Context";
const _CASG = "CreateAutoScalingGroup";
const _CCMS = "CustomizedCapacityMetricSpecification";
const _CD = "CheckpointDelay";
const _CDS = "CapacityDistributionStrategy";
const _CF = "CapacityForecast";
const _CIR = "CancelInstanceRefresh";
const _CLA = "CompleteLifecycleAction";
Expand Down
49 changes: 49 additions & 0 deletions codegen/sdk-codegen/aws-models/auto-scaling.json
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,12 @@
"traits": {
"smithy.api#documentation": "<p>An instance maintenance policy.</p>"
}
},
"AvailabilityZoneDistribution": {
"target": "com.amazonaws.autoscaling#AvailabilityZoneDistribution",
"traits": {
"smithy.api#documentation": "<p>\n The instance capacity distribution across Availability Zones.\n </p>"
}
}
},
"traits": {
Expand Down Expand Up @@ -2299,6 +2305,20 @@
}
}
},
"com.amazonaws.autoscaling#AvailabilityZoneDistribution": {
"type": "structure",
"members": {
"CapacityDistributionStrategy": {
"target": "com.amazonaws.autoscaling#CapacityDistributionStrategy",
"traits": {
"smithy.api#documentation": "<p>\n If launches fail in an Availability Zone, the following strategies are available. The default is <code>balanced-best-effort</code>. </p>\n <ul>\n <li>\n <p>\n <code>balanced-only</code> - If launches fail in an Availability Zone, Auto Scaling will continue to attempt to launch in the unhealthy zone to preserve a balanced distribution.</p>\n </li>\n <li>\n <p>\n <code>balanced-best-effort</code> - If launches fail in an Availability Zone, Auto Scaling will attempt to launch in another healthy Availability Zone instead.</p>\n </li>\n </ul>"
}
}
},
"traits": {
"smithy.api#documentation": "<p>\n Describes an Availability Zone distribution.\n </p>"
}
},
"com.amazonaws.autoscaling#AvailabilityZones": {
"type": "list",
"member": {
Expand Down Expand Up @@ -2625,6 +2645,23 @@
}
}
},
"com.amazonaws.autoscaling#CapacityDistributionStrategy": {
"type": "enum",
"members": {
"BALANCED_ONLY": {
"target": "smithy.api#Unit",
"traits": {
"smithy.api#enumValue": "balanced-only"
}
},
"BALANCED_BEST_EFFORT": {
"target": "smithy.api#Unit",
"traits": {
"smithy.api#enumValue": "balanced-best-effort"
}
}
}
},
"com.amazonaws.autoscaling#CapacityForecast": {
"type": "structure",
"members": {
Expand Down Expand Up @@ -3098,6 +3135,12 @@
"traits": {
"smithy.api#documentation": "<p>An instance maintenance policy. For more information, see <a href=\"https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-maintenance-policy.html\">Set instance maintenance policy</a> in the\n <i>Amazon EC2 Auto Scaling User Guide</i>.</p>"
}
},
"AvailabilityZoneDistribution": {
"target": "com.amazonaws.autoscaling#AvailabilityZoneDistribution",
"traits": {
"smithy.api#documentation": "<p>The instance capacity distribution across Availability Zones.</p>"
}
}
}
},
Expand Down Expand Up @@ -10912,6 +10955,12 @@
"traits": {
"smithy.api#documentation": "<p>An instance maintenance policy. For more information, see <a href=\"https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-instance-maintenance-policy.html\">Set instance maintenance policy</a> in the\n <i>Amazon EC2 Auto Scaling User Guide</i>.</p>"
}
},
"AvailabilityZoneDistribution": {
"target": "com.amazonaws.autoscaling#AvailabilityZoneDistribution",
"traits": {
"smithy.api#documentation": "<p>\n The instance capacity distribution across Availability Zones.\n </p>"
}
}
}
},
Expand Down

0 comments on commit 3589a0f

Please sign in to comment.