StartInstanceRefresh - Amazon EC2 Auto Scaling

StartInstanceRefresh

Starts a new instance refresh operation. An instance refresh performs a rolling replacement of all or some instances in an Auto Scaling group. Each instance is terminated first and then replaced, which temporarily reduces the capacity available within your Auto Scaling group.

This operation is part of the instance refresh feature in Amazon EC2 Auto Scaling, which helps you update instances in your Auto Scaling group. This feature is helpful, for example, when you have a new AMI or a new user data script. You just need to create a new launch template that specifies the new AMI or user data script. Then start an instance refresh to immediately begin the process of updating instances in the group.

If the call succeeds, it creates a new instance refresh request with a unique ID that you can use to track its progress. To query its status, call the DescribeInstanceRefreshes API. To describe the instance refreshes that have already run, call the DescribeInstanceRefreshes API. To cancel an instance refresh operation in progress, use the CancelInstanceRefresh API.

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

AutoScalingGroupName

The name of the Auto Scaling group.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 255.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Required: Yes

DesiredConfiguration

The desired configuration. For example, the desired configuration can specify a new launch template or a new version of the current launch template.

Once the instance refresh succeeds, Amazon EC2 Auto Scaling updates the settings of the Auto Scaling group to reflect the new desired configuration.

Note

When you specify a new launch template or a new version of the current launch template for your desired configuration, consider enabling the SkipMatching property in preferences. If it's enabled, Amazon EC2 Auto Scaling skips replacing instances that already use the specified launch template and version. This can help you reduce the number of replacements that are required to apply updates.

Type: DesiredConfiguration object

Required: No

Preferences

Set of preferences associated with the instance refresh request. If not provided, the default values are used.

Type: RefreshPreferences object

Required: No

Strategy

The strategy to use for the instance refresh. The only valid value is Rolling.

A rolling update helps you update your instances gradually. A rolling update can fail due to failed health checks or if instances are on standby or are protected from scale in. If the rolling update process fails, any instances that are replaced are not rolled back to their previous configuration.

Type: String

Valid Values: Rolling

Required: No

Response Elements

The following element is returned by the service.

InstanceRefreshId

A unique ID for tracking the progress of the request.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 255.

Pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\r\n\t]*

Errors

For information about the errors that are common to all actions, see Common Errors.

InstanceRefreshInProgress

The request failed because an active instance refresh operation already exists for the specified Auto Scaling group.

HTTP Status Code: 400

LimitExceeded

You have already reached a limit for your Amazon EC2 Auto Scaling resources (for example, Auto Scaling groups, launch configurations, or lifecycle hooks). For more information, see DescribeAccountLimits.

HTTP Status Code: 400

ResourceContention

You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

HTTP Status Code: 500

Examples

Example

This example illustrates one usage of StartInstanceRefresh.

Sample Request

https://autoscaling.amazonaws.com/?Action=StartInstanceRefresh &AutoScalingGroupName=my-asg &Preferences.InstanceWarmup=400 &Preferences.MinHealthyPercentage=50 &Version=2011-01-01 &AUTHPARAMS

Sample Response

<StartInstanceRefreshResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/"> <StartInstanceRefreshResult> <InstanceRefreshId>ccfd3c2f-edb3-470d-af32-52cc57d201ca</InstanceRefreshId> </StartInstanceRefreshResult> <ResponseMetadata> <RequestId>a9bbb1dd-ba59-4753-80a2-c662036187eb</RequestId> </ResponseMetadata> </StartInstanceRefreshResponse>

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: