AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Starts an instance refresh.

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 successful, the request's response contains a unique ID that you can use to track the progress of the instance refresh. 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 that is in progress, use the CancelInstanceRefresh API.

An instance refresh might fail for several reasons, such as EC2 launch failures, misconfigured health checks, or not ignoring or allowing the termination of instances that are in Standby state or protected from scale in. You can monitor for failed EC2 launches using the scaling activities. To find the scaling activities, call the DescribeScalingActivities API.

If you enable auto rollback, your Auto Scaling group will be rolled back automatically when the instance refresh fails. You can enable this feature before starting an instance refresh by specifying the AutoRollback property in the instance refresh preferences. Otherwise, to roll back an instance refresh before it finishes, use the RollbackInstanceRefresh API.

Note:

For .NET Core this operation is only available in asynchronous form. Please refer to StartInstanceRefreshAsync.

Namespace: Amazon.AutoScaling
Assembly: AWSSDK.AutoScaling.dll
Version: 3.x.y.z

Syntax

C#
public abstract StartInstanceRefreshResponse StartInstanceRefresh(
         StartInstanceRefreshRequest request
)

Parameters

request
Type: Amazon.AutoScaling.Model.StartInstanceRefreshRequest

Container for the necessary parameters to execute the StartInstanceRefresh service method.

Return Value


The response from the StartInstanceRefresh service method, as returned by AutoScaling.

Exceptions

ExceptionCondition
InstanceRefreshInProgressException The request failed because an active instance refresh already exists for the specified Auto Scaling group.
LimitExceededException 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 in the Amazon EC2 Auto Scaling API Reference.
ResourceContentionException You already have a pending update to an Amazon EC2 Auto Scaling resource (for example, an Auto Scaling group, instance, or load balancer).

Examples

This example starts an instance refresh for the specified Auto Scaling group.

To start an instance refresh


var client = new AmazonAutoScalingClient();
var response = client.StartInstanceRefresh(new StartInstanceRefreshRequest 
{
    AutoScalingGroupName = "my-auto-scaling-group",
    DesiredConfiguration = new DesiredConfiguration { LaunchTemplate = new LaunchTemplateSpecification {
        LaunchTemplateName = "my-template-for-auto-scaling",
        Version = "$Latest"
    } },
    Preferences = new RefreshPreferences {
        AlarmSpecification = new AlarmSpecification { Alarms = new List<string> {
            "my-alarm"
        } },
        AutoRollback = true,
        InstanceWarmup = 200,
        MaxHealthyPercentage = 120,
        MinHealthyPercentage = 90
    }
});

string instanceRefreshId = response.InstanceRefreshId;

            

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5

See Also