Skip to content

Commit

Permalink
feat(client-auto-scaling): You can now configure an instance refresh …
Browse files Browse the repository at this point in the history
…to set its status to 'failed' when it detects that a specified CloudWatch alarm has gone into the ALARM state. You can also choose to roll back the instance refresh automatically when the alarm threshold is met.
  • Loading branch information
awstools committed Jul 31, 2023
1 parent a1403dd commit 186216f
Show file tree
Hide file tree
Showing 6 changed files with 1,349 additions and 255 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export interface DescribeInstanceRefreshesCommandOutput extends DescribeInstance
* // AutoRollback: true || false,
* // ScaleInProtectedInstances: "Refresh" || "Ignore" || "Wait",
* // StandbyInstances: "Terminate" || "Ignore" || "Wait",
* // AlarmSpecification: { // AlarmSpecification
* // Alarms: [ // AlarmList
* // "STRING_VALUE",
* // ],
* // },
* // },
* // DesiredConfiguration: { // DesiredConfiguration
* // LaunchTemplate: { // LaunchTemplateSpecification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ export interface StartInstanceRefreshCommandOutput extends StartInstanceRefreshA
* AutoRollback: true || false,
* ScaleInProtectedInstances: "Refresh" || "Ignore" || "Wait",
* StandbyInstances: "Terminate" || "Ignore" || "Wait",
* AlarmSpecification: { // AlarmSpecification
* Alarms: [ // AlarmList
* "STRING_VALUE",
* ],
* },
* },
* };
* const command = new StartInstanceRefreshCommand(input);
Expand Down
2 changes: 1 addition & 1 deletion clients/client-auto-scaling/src/endpoint/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ o={[t]:"booleanEquals",[u]:[true,{[t]:f,[u]:[n,"supportsDualStack"]}]},
p=[j],
q=[k],
r=[{[v]:"Region"}];
const _data={version:"1.0",parameters:{Region:g,UseDualStack:h,UseFIPS:h,Endpoint:g},rules:[{conditions:[{[t]:a,[u]:[i]}],type:b,rules:[{conditions:p,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:c},{type:b,rules:[{conditions:q,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:c},{endpoint:{url:i,properties:l,headers:l},type:d}]}]},{type:b,rules:[{conditions:[{[t]:a,[u]:r}],type:b,rules:[{conditions:[{[t]:"aws.partition",[u]:r,assign:e}],type:b,rules:[{conditions:[j,k],type:b,rules:[{conditions:[m,o],type:b,rules:[{type:b,rules:[{endpoint:{url:"https://autoscaling-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:l,headers:l},type:d}]}]},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:c}]},{conditions:p,type:b,rules:[{conditions:[m],type:b,rules:[{type:b,rules:[{conditions:[{[t]:"stringEquals",[u]:["aws-us-gov",{[t]:f,[u]:[n,"name"]}]}],endpoint:{url:"https://autoscaling.{Region}.amazonaws.com",properties:l,headers:l},type:d},{endpoint:{url:"https://autoscaling-fips.{Region}.{PartitionResult#dnsSuffix}",properties:l,headers:l},type:d}]}]},{error:"FIPS is enabled but this partition does not support FIPS",type:c}]},{conditions:q,type:b,rules:[{conditions:[o],type:b,rules:[{type:b,rules:[{endpoint:{url:"https://autoscaling.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:l,headers:l},type:d}]}]},{error:"DualStack is enabled but this partition does not support DualStack",type:c}]},{type:b,rules:[{endpoint:{url:"https://autoscaling.{Region}.{PartitionResult#dnsSuffix}",properties:l,headers:l},type:d}]}]}]},{error:"Invalid Configuration: Missing Region",type:c}]}]};
const _data={version:"1.0",parameters:{Region:g,UseDualStack:h,UseFIPS:h,Endpoint:g},rules:[{conditions:[{[t]:a,[u]:[i]}],type:b,rules:[{conditions:p,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:c},{conditions:q,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:c},{endpoint:{url:i,properties:l,headers:l},type:d}]},{conditions:[{[t]:a,[u]:r}],type:b,rules:[{conditions:[{[t]:"aws.partition",[u]:r,assign:e}],type:b,rules:[{conditions:[j,k],type:b,rules:[{conditions:[m,o],type:b,rules:[{endpoint:{url:"https://autoscaling-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:l,headers:l},type:d}]},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:c}]},{conditions:p,type:b,rules:[{conditions:[m],type:b,rules:[{conditions:[{[t]:"stringEquals",[u]:["aws-us-gov",{[t]:f,[u]:[n,"name"]}]}],endpoint:{url:"https://autoscaling.{Region}.amazonaws.com",properties:l,headers:l},type:d},{endpoint:{url:"https://autoscaling-fips.{Region}.{PartitionResult#dnsSuffix}",properties:l,headers:l},type:d}]},{error:"FIPS is enabled but this partition does not support FIPS",type:c}]},{conditions:q,type:b,rules:[{conditions:[o],type:b,rules:[{endpoint:{url:"https://autoscaling.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:l,headers:l},type:d}]},{error:"DualStack is enabled but this partition does not support DualStack",type:c}]},{endpoint:{url:"https://autoscaling.{Region}.{PartitionResult#dnsSuffix}",properties:l,headers:l},type:d}]}]},{error:"Invalid Configuration: Missing Region",type:c}]};
export const ruleSet: RuleSetObject = _data;
29 changes: 26 additions & 3 deletions clients/client-auto-scaling/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ export interface Alarm {
AlarmARN?: string;
}

/**
* @public
* <p>Specifies the CloudWatch alarm specification to use in an instance refresh.</p>
*/
export interface AlarmSpecification {
/**
* <p>The names of one or more CloudWatch alarms to monitor for the instance refresh.</p>
*/
Alarms?: string[];
}

/**
* @public
* <p>You already have an Auto Scaling group or launch configuration with this name.</p>
Expand Down Expand Up @@ -3406,7 +3417,8 @@ export interface RefreshPreferences {

/**
* <p>(Optional) Indicates whether to roll back the Auto Scaling group to its previous configuration
* if the instance refresh fails. The default is <code>false</code>.</p>
* if the instance refresh fails or a CloudWatch alarm threshold is met. The default is
* <code>false</code>.</p>
* <p>A rollback is not supported in the following situations: </p>
* <ul>
* <li>
Expand All @@ -3421,6 +3433,8 @@ export interface RefreshPreferences {
* <code>$Default</code> version.</p>
* </li>
* </ul>
* <p>For more information, see <a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/instance-refresh-rollback.html">Undo changes with a
* rollback</a> in the <i>Amazon EC2 Auto Scaling User Guide</i>.</p>
*/
AutoRollback?: boolean;

Expand Down Expand Up @@ -3469,6 +3483,12 @@ export interface RefreshPreferences {
* </dl>
*/
StandbyInstances?: StandbyInstances | string;

/**
* <p>(Optional) The CloudWatch alarm specification. CloudWatch alarms can be used to identify any
* issues and fail the operation if an alarm threshold is met.</p>
*/
AlarmSpecification?: AlarmSpecification;
}

/**
Expand Down Expand Up @@ -5063,8 +5083,8 @@ export interface StepAdjustment {

/**
* <p>The amount by which to scale, based on the specified adjustment type. A positive value
* adds to the current capacity while a negative number removes from the current
* capacity. For exact capacity, you must specify a non-negative value.</p>
* adds to the current capacity while a negative number removes from the current capacity.
* For exact capacity, you must specify a non-negative value.</p>
*/
ScalingAdjustment: number | undefined;
}
Expand Down Expand Up @@ -7229,6 +7249,9 @@ export interface StartInstanceRefreshType {
* <p>Checkpoints</p>
* </li>
* <li>
* <p>CloudWatch alarms</p>
* </li>
* <li>
* <p>Skip matching</p>
* </li>
* </ul>
Expand Down
69 changes: 69 additions & 0 deletions clients/client-auto-scaling/src/protocols/Aws_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ import {
ActivityType,
AdjustmentType,
Alarm,
AlarmSpecification,
AlreadyExistsFault,
AttachInstancesQuery,
AttachLoadBalancersResultType,
Expand Down Expand Up @@ -4863,6 +4864,40 @@ const se_ActivityIds = (input: string[], context: __SerdeContext): any => {
return entries;
};

/**
* serializeAws_queryAlarmList
*/
const se_AlarmList = (input: string[], context: __SerdeContext): any => {
const entries: any = {};
let counter = 1;
for (const entry of input) {
if (entry === null) {
continue;
}
entries[`member.${counter}`] = entry;
counter++;
}
return entries;
};

/**
* serializeAws_queryAlarmSpecification
*/
const se_AlarmSpecification = (input: AlarmSpecification, context: __SerdeContext): any => {
const entries: any = {};
if (input.Alarms != null) {
const memberEntries = se_AlarmList(input.Alarms, context);
if (input.Alarms?.length === 0) {
entries.Alarms = [];
}
Object.entries(memberEntries).forEach(([key, value]) => {
const loc = `Alarms.${key}`;
entries[loc] = value;
});
}
return entries;
};

/**
* serializeAws_queryAllowedInstanceTypes
*/
Expand Down Expand Up @@ -7539,6 +7574,13 @@ const se_RefreshPreferences = (input: RefreshPreferences, context: __SerdeContex
if (input.StandbyInstances != null) {
entries["StandbyInstances"] = input.StandbyInstances;
}
if (input.AlarmSpecification != null) {
const memberEntries = se_AlarmSpecification(input.AlarmSpecification, context);
Object.entries(memberEntries).forEach(([key, value]) => {
const loc = `AlarmSpecification.${key}`;
entries[loc] = value;
});
}
return entries;
};

Expand Down Expand Up @@ -8337,6 +8379,17 @@ const de_Alarm = (output: any, context: __SerdeContext): Alarm => {
return contents;
};

/**
* deserializeAws_queryAlarmList
*/
const de_AlarmList = (output: any, context: __SerdeContext): string[] => {
return (output || [])
.filter((e: any) => e != null)
.map((entry: any) => {
return __expectString(entry) as any;
});
};

/**
* deserializeAws_queryAlarms
*/
Expand All @@ -8348,6 +8401,19 @@ const de_Alarms = (output: any, context: __SerdeContext): Alarm[] => {
});
};

/**
* deserializeAws_queryAlarmSpecification
*/
const de_AlarmSpecification = (output: any, context: __SerdeContext): AlarmSpecification => {
const contents: any = {};
if (output.Alarms === "") {
contents.Alarms = [];
} else if (output["Alarms"] !== undefined && output["Alarms"]["member"] !== undefined) {
contents.Alarms = de_AlarmList(__getArrayIfSingleItem(output["Alarms"]["member"]), context);
}
return contents;
};

/**
* deserializeAws_queryAllowedInstanceTypes
*/
Expand Down Expand Up @@ -10654,6 +10720,9 @@ const de_RefreshPreferences = (output: any, context: __SerdeContext): RefreshPre
if (output["StandbyInstances"] !== undefined) {
contents.StandbyInstances = __expectString(output["StandbyInstances"]);
}
if (output["AlarmSpecification"] !== undefined) {
contents.AlarmSpecification = de_AlarmSpecification(output["AlarmSpecification"], context);
}
return contents;
};

Expand Down
Loading

0 comments on commit 186216f

Please sign in to comment.