Show / Hide Table of Contents

Class Group

Provides an AutoScaling Group resource.

Note: You must specify either launch_configuration, launch_template, or mixed_instances_policy.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var test = new Aws.Ec2.PlacementGroup("test", new Aws.Ec2.PlacementGroupArgs
    {
        Strategy = "cluster",
    });
    var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
    {
        DesiredCapacity = 4,
        ForceDelete = true,
        HealthCheckGracePeriod = 300,
        HealthCheckType = "ELB",
        InitialLifecycleHooks = 
        {
            new Aws.AutoScaling.Inputs.GroupInitialLifecycleHookArgs
            {
                DefaultResult = "CONTINUE",
                HeartbeatTimeout = 2000,
                LifecycleTransition = "autoscaling:EC2_INSTANCE_LAUNCHING",
                Name = "foobar",
                NotificationMetadata = @"{
""foo"": ""bar""
}

",
                NotificationTargetArn = "arn:aws:sqs:us-east-1:444455556666:queue1*",
                RoleArn = "arn:aws:iam::123456789012:role/S3Access",
            },
        },
        LaunchConfiguration = aws_launch_configuration.Foobar.Name,
        MaxSize = 5,
        MinSize = 2,
        PlacementGroup = test.Id,
        Tags = 
        {
            new Aws.AutoScaling.Inputs.GroupTagArgs
            {
                Key = "foo",
                PropagateAtLaunch = true,
                Value = "bar",
            },
            new Aws.AutoScaling.Inputs.GroupTagArgs
            {
                Key = "lorem",
                PropagateAtLaunch = false,
                Value = "ipsum",
            },
        },
        VpcZoneIdentifiers = 
        {
            aws_subnet.Example1.Id,
            aws_subnet.Example2.Id,
        },
    });
}

}

With Latest Version Of Launch Template

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var foobar = new Aws.Ec2.LaunchTemplate("foobar", new Aws.Ec2.LaunchTemplateArgs
    {
        ImageId = "ami-1a2b3c",
        InstanceType = "t2.micro",
        NamePrefix = "foobar",
    });
    var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
    {
        AvailabilityZones = 
        {
            "us-east-1a",
        },
        DesiredCapacity = 1,
        LaunchTemplate = new Aws.AutoScaling.Inputs.GroupLaunchTemplateArgs
        {
            Id = foobar.Id,
            Version = "$$Latest",
        },
        MaxSize = 1,
        MinSize = 1,
    });
}

}

Mixed Instances Policy

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var exampleLaunchTemplate = new Aws.Ec2.LaunchTemplate("exampleLaunchTemplate", new Aws.Ec2.LaunchTemplateArgs
    {
        ImageId = data.Aws_ami.Example.Id,
        InstanceType = "c5.large",
        NamePrefix = "example",
    });
    var exampleGroup = new Aws.AutoScaling.Group("exampleGroup", new Aws.AutoScaling.GroupArgs
    {
        AvailabilityZones = 
        {
            "us-east-1a",
        },
        DesiredCapacity = 1,
        MaxSize = 1,
        MinSize = 1,
        MixedInstancesPolicy = new Aws.AutoScaling.Inputs.GroupMixedInstancesPolicyArgs
        {
            LaunchTemplate = new Aws.AutoScaling.Inputs.GroupMixedInstancesPolicyLaunchTemplateArgs
            {
                LaunchTemplateSpecification = new Aws.AutoScaling.Inputs.GroupMixedInstancesPolicyLaunchTemplateLaunchTemplateSpecificationArgs
                {
                    LaunchTemplateId = exampleLaunchTemplate.Id,
                },
                Override = 
                {

                    {
                        { "instanceType", "c4.large" },
                        { "weightedCapacity", "3" },
                    },

                    {
                        { "instanceType", "c3.large" },
                        { "weightedCapacity", "2" },
                    },
                },
            },
        },
    });
}

}

Waiting for Capacity

A newly-created ASG is initially empty and begins to scale to min_size (or desired_capacity, if specified) by launching instances using the provided Launch Configuration. These instances take time to launch and boot.

On ASG Update, changes to these values also take time to result in the target number of instances providing service.

This provider provides two mechanisms to help consistently manage ASG scale up time across dependent resources.

Waiting for ASG Capacity

The first is default behavior. This provider waits after ASG creation for min_size (or desired_capacity, if specified) healthy instances to show up in the ASG before continuing.

If min_size or desired_capacity are changed in a subsequent update, this provider will also wait for the correct number of healthy instances before continuing.

This provider considers an instance "healthy" when the ASG reports HealthStatus: "Healthy" and LifecycleState: "InService". See the AWS AutoScaling Docs for more information on an ASG's lifecycle.

This provider will wait for healthy instances for up to wait_for_capacity_timeout. If ASG creation is taking more than a few minutes, it's worth investigating for scaling activity errors, which can be caused by problems with the selected Launch Configuration.

Setting wait_for_capacity_timeout to "0" disables ASG Capacity waiting.

Waiting for ELB Capacity

The second mechanism is optional, and affects ASGs with attached ELBs specified via the load_balancers attribute or with ALBs specified with target_group_arns.

The min_elb_capacity parameter causes this provider to wait for at least the requested number of instances to show up "InService" in all attached ELBs during ASG creation. It has no effect on ASG updates.

If wait_for_elb_capacity is set, this provider will wait for exactly that number of Instances to be "InService" in all attached ELBs on both creation and updates.

These parameters can be used to ensure that service is being provided before this provider moves on. If new instances don't pass the ELB's health checks for any reason, the deployment will time out, and the ASG will be marked as tainted (i.e. marked to be destroyed in a follow up run).

As with ASG Capacity, this provider will wait for up to wait_for_capacity_timeout for the proper number of instances to be healthy.

Troubleshooting Capacity Waiting Timeouts

If ASG creation takes more than a few minutes, this could indicate one of a number of configuration problems. See the AWS Docs on Load Balancer Troubleshooting for more information.

Inheritance
System.Object
Resource
CustomResource
Group
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.AutoScaling
Assembly: Pulumi.Aws.dll
Syntax
public class Group : CustomResource

Constructors

View Source

Group(String, GroupArgs, CustomResourceOptions)

Create a Group resource with the given unique name, arguments, and options.

Declaration
public Group(string name, GroupArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

GroupArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Arn

The ARN for this AutoScaling Group

Declaration
public Output<string> Arn { get; }
Property Value
Type Description
Output<System.String>
View Source

AvailabilityZones

A list of one or more availability zones for the group. This parameter should not be specified when using vpc_zone_identifier.

Declaration
public Output<ImmutableArray<string>> AvailabilityZones { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

DefaultCooldown

The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.

Declaration
public Output<int> DefaultCooldown { get; }
Property Value
Type Description
Output<System.Int32>
View Source

DesiredCapacity

The number of Amazon EC2 instances that should be running in the group. (See also Waiting for Capacity below.)

Declaration
public Output<int> DesiredCapacity { get; }
Property Value
Type Description
Output<System.Int32>
View Source

EnabledMetrics

A list of metrics to collect. The allowed values are GroupDesiredCapacity, GroupInServiceCapacity, GroupPendingCapacity, GroupMinSize, GroupMaxSize, GroupInServiceInstances, GroupPendingInstances, GroupStandbyInstances, GroupStandbyCapacity, GroupTerminatingCapacity, GroupTerminatingInstances, GroupTotalCapacity, GroupTotalInstances.

Declaration
public Output<ImmutableArray<string>> EnabledMetrics { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

ForceDelete

Allows deleting the autoscaling group without waiting for all instances in the pool to terminate. You can force an autoscaling group to delete even if it's in the process of scaling a resource. Normally, this provider drains all the instances before deleting the group. This bypasses that behavior and potentially leaves resources dangling.

Declaration
public Output<bool?> ForceDelete { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

HealthCheckGracePeriod

Time (in seconds) after instance comes into service before checking health.

Declaration
public Output<int?> HealthCheckGracePeriod { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

HealthCheckType

"EC2" or "ELB". Controls how health checking is done.

Declaration
public Output<string> HealthCheckType { get; }
Property Value
Type Description
Output<System.String>
View Source

InitialLifecycleHooks

One or more Lifecycle Hooks to attach to the autoscaling group before instances are launched. The syntax is exactly the same as the separate aws.autoscaling.LifecycleHook resource, without the autoscaling_group_name attribute. Please note that this will only work when creating a new autoscaling group. For all other use-cases, please use aws.autoscaling.LifecycleHook resource.

Declaration
public Output<ImmutableArray<GroupInitialLifecycleHook>> InitialLifecycleHooks { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<GroupInitialLifecycleHook>>
View Source

LaunchConfiguration

The name of the launch configuration to use.

Declaration
public Output<string> LaunchConfiguration { get; }
Property Value
Type Description
Output<System.String>
View Source

LaunchTemplate

Nested argument containing launch template settings along with the overrides to specify multiple instance types and weights. Defined below.

Declaration
public Output<GroupLaunchTemplate> LaunchTemplate { get; }
Property Value
Type Description
Output<GroupLaunchTemplate>
View Source

LoadBalancers

A list of elastic load balancer names to add to the autoscaling group names. Only valid for classic load balancers. For ALBs, use target_group_arns instead.

Declaration
public Output<ImmutableArray<string>> LoadBalancers { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

MaxInstanceLifetime

The maximum amount of time, in seconds, that an instance can be in service, values must be either equal to 0 or between 604800 and 31536000 seconds.

Declaration
public Output<int?> MaxInstanceLifetime { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

MaxSize

The maximum size of the auto scale group.

Declaration
public Output<int> MaxSize { get; }
Property Value
Type Description
Output<System.Int32>
View Source

MetricsGranularity

The granularity to associate with the metrics to collect. The only valid value is 1Minute. Default is 1Minute.

Declaration
public Output<string> MetricsGranularity { get; }
Property Value
Type Description
Output<System.String>
View Source

MinElbCapacity

Setting this causes this provider to wait for this number of instances from this autoscaling group to show up healthy in the ELB only on creation. Updates will not wait on ELB instance number changes. (See also Waiting for Capacity below.)

Declaration
public Output<int?> MinElbCapacity { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>
View Source

MinSize

The minimum size of the auto scale group. (See also Waiting for Capacity below.)

Declaration
public Output<int> MinSize { get; }
Property Value
Type Description
Output<System.Int32>
View Source

MixedInstancesPolicy

Configuration block containing settings to define launch targets for Auto Scaling groups. Defined below.

Declaration
public Output<GroupMixedInstancesPolicy> MixedInstancesPolicy { get; }
Property Value
Type Description
Output<GroupMixedInstancesPolicy>
View Source

Name

The name of the auto scaling group. By default generated by this provider.

Declaration
public Output<string> Name { get; }
Property Value
Type Description
Output<System.String>
View Source

NamePrefix

Creates a unique name beginning with the specified prefix. Conflicts with name.

Declaration
public Output<string> NamePrefix { get; }
Property Value
Type Description
Output<System.String>
View Source

PlacementGroup

The name of the placement group into which you'll launch your instances, if any.

Declaration
public Output<string> PlacementGroup { get; }
Property Value
Type Description
Output<System.String>
View Source

ProtectFromScaleIn

Allows setting instance protection. The autoscaling group will not select instances with this setting for terminination during scale in events.

Declaration
public Output<bool?> ProtectFromScaleIn { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

ServiceLinkedRoleArn

The ARN of the service-linked role that the ASG will use to call other AWS services

Declaration
public Output<string> ServiceLinkedRoleArn { get; }
Property Value
Type Description
Output<System.String>
View Source

SuspendedProcesses

A list of processes to suspend for the AutoScaling Group. The allowed values are Launch, Terminate, HealthCheck, ReplaceUnhealthy, AZRebalance, AlarmNotification, ScheduledActions, AddToLoadBalancer. Note that if you suspend either the Launch or Terminate process types, it can prevent your autoscaling group from functioning properly.

Declaration
public Output<ImmutableArray<string>> SuspendedProcesses { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

Tags

A list of tag blocks. Tags documented below.

Declaration
public Output<ImmutableArray<GroupTag>> Tags { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<GroupTag>>
View Source

TagsCollection

A list of tag blocks (maps). Tags documented below.

Declaration
public Output<ImmutableArray<ImmutableDictionary<string, object>>> TagsCollection { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.Collections.Immutable.ImmutableDictionary<System.String, System.Object>>>
View Source

TargetGroupArns

A list of aws.alb.TargetGroup ARNs, for use with Application or Network Load Balancing.

Declaration
public Output<ImmutableArray<string>> TargetGroupArns { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

TerminationPolicies

A list of policies to decide how the instances in the auto scale group should be terminated. The allowed values are OldestInstance, NewestInstance, OldestLaunchConfiguration, ClosestToNextInstanceHour, OldestLaunchTemplate, AllocationStrategy, Default.

Declaration
public Output<ImmutableArray<string>> TerminationPolicies { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

VpcZoneIdentifiers

A list of subnet IDs to launch resources in.

Declaration
public Output<ImmutableArray<string>> VpcZoneIdentifiers { get; }
Property Value
Type Description
Output<System.Collections.Immutable.ImmutableArray<System.String>>
View Source

WaitForCapacityTimeout

A maximum duration that this provider should wait for ASG instances to be healthy before timing out. (See also Waiting for Capacity below.) Setting this to "0" causes this provider to skip all Capacity Waiting behavior.

Declaration
public Output<string> WaitForCapacityTimeout { get; }
Property Value
Type Description
Output<System.String>
View Source

WaitForElbCapacity

Setting this will cause this provider to wait for exactly this number of healthy instances from this autoscaling group in all attached load balancers on both create and update operations. (Takes precedence over min_elb_capacity behavior.) (See also Waiting for Capacity below.)

Declaration
public Output<int?> WaitForElbCapacity { get; }
Property Value
Type Description
Output<System.Nullable<System.Int32>>

Methods

View Source

Get(String, Input<String>, GroupState, CustomResourceOptions)

Get an existing Group resource's state with the given name, ID, and optional extra properties used to qualify the lookup.

Declaration
public static Group Get(string name, Input<string> id, GroupState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

GroupState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
Group
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.