Skip to content

Start Instance Refresh

autoscaling_start_instance_refresh R Documentation

Starts an instance refresh

Description

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 describe_instance_refreshes API. To describe the instance refreshes that have already run, call the describe_instance_refreshes API. To cancel an instance refresh that is in progress, use the cancel_instance_refresh 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 describe_scaling_activities 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 rollback_instance_refresh API.

Usage

autoscaling_start_instance_refresh(AutoScalingGroupName, Strategy,
  DesiredConfiguration, Preferences)

Arguments

AutoScalingGroupName

[required] The name of the Auto Scaling group.

Strategy

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

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.

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 instance types. This can help you reduce the number of replacements that are required to apply updates.

Preferences

Sets your preferences for the instance refresh so that it performs as expected when you start it. Includes the instance warmup time, the minimum and maximum healthy percentages, and the behaviors that you want Amazon EC2 Auto Scaling to use if instances that are in Standby state or protected from scale in are found. You can also choose to enable additional features, such as the following:

  • Auto rollback

  • Checkpoints

  • CloudWatch alarms

  • Skip matching

Value

A list with the following syntax:

list(
  InstanceRefreshId = "string"
)

Request syntax

svc$start_instance_refresh(
  AutoScalingGroupName = "string",
  Strategy = "Rolling",
  DesiredConfiguration = list(
    LaunchTemplate = list(
      LaunchTemplateId = "string",
      LaunchTemplateName = "string",
      Version = "string"
    ),
    MixedInstancesPolicy = list(
      LaunchTemplate = list(
        LaunchTemplateSpecification = list(
          LaunchTemplateId = "string",
          LaunchTemplateName = "string",
          Version = "string"
        ),
        Overrides = list(
          list(
            InstanceType = "string",
            WeightedCapacity = "string",
            LaunchTemplateSpecification = list(
              LaunchTemplateId = "string",
              LaunchTemplateName = "string",
              Version = "string"
            ),
            InstanceRequirements = list(
              VCpuCount = list(
                Min = 123,
                Max = 123
              ),
              MemoryMiB = list(
                Min = 123,
                Max = 123
              ),
              CpuManufacturers = list(
                "intel"|"amd"|"amazon-web-services"
              ),
              MemoryGiBPerVCpu = list(
                Min = 123.0,
                Max = 123.0
              ),
              ExcludedInstanceTypes = list(
                "string"
              ),
              InstanceGenerations = list(
                "current"|"previous"
              ),
              SpotMaxPricePercentageOverLowestPrice = 123,
              MaxSpotPriceAsPercentageOfOptimalOnDemandPrice = 123,
              OnDemandMaxPricePercentageOverLowestPrice = 123,
              BareMetal = "included"|"excluded"|"required",
              BurstablePerformance = "included"|"excluded"|"required",
              RequireHibernateSupport = TRUE|FALSE,
              NetworkInterfaceCount = list(
                Min = 123,
                Max = 123
              ),
              LocalStorage = "included"|"excluded"|"required",
              LocalStorageTypes = list(
                "hdd"|"ssd"
              ),
              TotalLocalStorageGB = list(
                Min = 123.0,
                Max = 123.0
              ),
              BaselineEbsBandwidthMbps = list(
                Min = 123,
                Max = 123
              ),
              AcceleratorTypes = list(
                "gpu"|"fpga"|"inference"
              ),
              AcceleratorCount = list(
                Min = 123,
                Max = 123
              ),
              AcceleratorManufacturers = list(
                "nvidia"|"amd"|"amazon-web-services"|"xilinx"
              ),
              AcceleratorNames = list(
                "a100"|"v100"|"k80"|"t4"|"m60"|"radeon-pro-v520"|"vu9p"
              ),
              AcceleratorTotalMemoryMiB = list(
                Min = 123,
                Max = 123
              ),
              NetworkBandwidthGbps = list(
                Min = 123.0,
                Max = 123.0
              ),
              AllowedInstanceTypes = list(
                "string"
              )
            )
          )
        )
      ),
      InstancesDistribution = list(
        OnDemandAllocationStrategy = "string",
        OnDemandBaseCapacity = 123,
        OnDemandPercentageAboveBaseCapacity = 123,
        SpotAllocationStrategy = "string",
        SpotInstancePools = 123,
        SpotMaxPrice = "string"
      )
    )
  ),
  Preferences = list(
    MinHealthyPercentage = 123,
    InstanceWarmup = 123,
    CheckpointPercentages = list(
      123
    ),
    CheckpointDelay = 123,
    SkipMatching = TRUE|FALSE,
    AutoRollback = TRUE|FALSE,
    ScaleInProtectedInstances = "Refresh"|"Ignore"|"Wait",
    StandbyInstances = "Terminate"|"Ignore"|"Wait",
    AlarmSpecification = list(
      Alarms = list(
        "string"
      )
    ),
    MaxHealthyPercentage = 123
  )
)

Examples

## Not run: 
# This example starts an instance refresh for the specified Auto Scaling
# group.
svc$start_instance_refresh(
  AutoScalingGroupName = "my-auto-scaling-group",
  DesiredConfiguration = list(
    LaunchTemplate = list(
      LaunchTemplateName = "my-template-for-auto-scaling",
      Version = "$Latest"
    )
  ),
  Preferences = list(
    AlarmSpecification = list(
      Alarms = list(
        "my-alarm"
      )
    ),
    AutoRollback = TRUE,
    InstanceWarmup = 200L,
    MaxHealthyPercentage = 120L,
    MinHealthyPercentage = 90L
  )
)

## End(Not run)