Show / Hide Table of Contents

Namespace Pulumi.Aws.AutoScaling

Classes

Attachment

Provides an AutoScaling Attachment resource.

NOTE on AutoScaling Groups and ASG Attachments: This provider currently provides both a standalone ASG Attachment resource (describing an ASG attached to an ELB), and an AutoScaling Group resource with load_balancers defined in-line. At this time you cannot use an ASG with in-line load balancers in conjunction with an ASG Attachment resource. Doing so will cause a conflict and will overwrite attachments.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    // Create a new load balancer attachment
    var asgAttachmentBar = new Aws.AutoScaling.Attachment("asgAttachmentBar", new Aws.AutoScaling.AttachmentArgs
    {
        AutoscalingGroupName = aws_autoscaling_group.Asg.Id,
        Elb = aws_elb.Bar.Id,
    });
}

}

AttachmentArgs

AttachmentState

GetGroup

GetGroupArgs

GetGroupResult

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.

GroupArgs

GroupState

LifecycleHook

Provides an AutoScaling Lifecycle Hook resource.

NOTE: This provider has two types of ways you can add lifecycle hooks - via the initial_lifecycle_hook attribute from the aws.autoscaling.Group resource, or via this one. Hooks added via this resource will not be added until the autoscaling group has been created, and depending on your capacity settings, after the initial instances have been launched, creating unintended behavior. If you need hooks to run on all instances, add them with initial_lifecycle_hook in aws.autoscaling.Group, but take care to not duplicate those hooks with this resource.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var foobarGroup = new Aws.AutoScaling.Group("foobarGroup", new Aws.AutoScaling.GroupArgs
    {
        AvailabilityZones = 
        {
            "us-west-2a",
        },
        HealthCheckType = "EC2",
        Tags = 
        {
            new Aws.AutoScaling.Inputs.GroupTagArgs
            {
                Key = "Foo",
                PropagateAtLaunch = true,
                Value = "foo-bar",
            },
        },
        TerminationPolicies = 
        {
            "OldestInstance",
        },
    });
    var foobarLifecycleHook = new Aws.AutoScaling.LifecycleHook("foobarLifecycleHook", new Aws.AutoScaling.LifecycleHookArgs
    {
        AutoscalingGroupName = foobarGroup.Name,
        DefaultResult = "CONTINUE",
        HeartbeatTimeout = 2000,
        LifecycleTransition = "autoscaling:EC2_INSTANCE_LAUNCHING",
        NotificationMetadata = @"{
""foo"": ""bar""
}

",
        NotificationTargetArn = "arn:aws:sqs:us-east-1:444455556666:queue1*",
        RoleArn = "arn:aws:iam::123456789012:role/S3Access",
    });
}

}

LifecycleHookArgs

LifecycleHookState

Notification

Provides an AutoScaling Group with Notification support, via SNS Topics. Each of the notifications map to a Notification Configuration inside Amazon Web Services, and are applied to each AutoScaling Group you supply.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var example = new Aws.Sns.Topic("example", new Aws.Sns.TopicArgs
    {
    });
    var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
    {
    });
    var foo = new Aws.AutoScaling.Group("foo", new Aws.AutoScaling.GroupArgs
    {
    });
    var exampleNotifications = new Aws.AutoScaling.Notification("exampleNotifications", new Aws.AutoScaling.NotificationArgs
    {
        GroupNames = 
        {
            bar.Name,
            foo.Name,
        },
        Notifications = 
        {
            "autoscaling:EC2_INSTANCE_LAUNCH",
            "autoscaling:EC2_INSTANCE_TERMINATE",
            "autoscaling:EC2_INSTANCE_LAUNCH_ERROR",
            "autoscaling:EC2_INSTANCE_TERMINATE_ERROR",
        },
        TopicArn = example.Arn,
    });
}

}

NotificationArgs

NotificationState

Policy

Provides an AutoScaling Scaling Policy resource.

NOTE: You may want to omit desired_capacity attribute from attached aws.autoscaling.Group when using autoscaling policies. It's good practice to pick either manual or dynamic (policy-based) scaling.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var bar = new Aws.AutoScaling.Group("bar", new Aws.AutoScaling.GroupArgs
    {
        AvailabilityZones = 
        {
            "us-east-1a",
        },
        ForceDelete = true,
        HealthCheckGracePeriod = 300,
        HealthCheckType = "ELB",
        LaunchConfiguration = aws_launch_configuration.Foo.Name,
        MaxSize = 5,
        MinSize = 2,
    });
    var bat = new Aws.AutoScaling.Policy("bat", new Aws.AutoScaling.PolicyArgs
    {
        AdjustmentType = "ChangeInCapacity",
        AutoscalingGroupName = bar.Name,
        Cooldown = 300,
        ScalingAdjustment = 4,
    });
}

}

PolicyArgs

PolicyState

Schedule

Provides an AutoScaling Schedule resource.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var foobarGroup = new Aws.AutoScaling.Group("foobarGroup", new Aws.AutoScaling.GroupArgs
    {
        AvailabilityZones = 
        {
            "us-west-2a",
        },
        ForceDelete = true,
        HealthCheckGracePeriod = 300,
        HealthCheckType = "ELB",
        MaxSize = 1,
        MinSize = 1,
        TerminationPolicies = 
        {
            "OldestInstance",
        },
    });
    var foobarSchedule = new Aws.AutoScaling.Schedule("foobarSchedule", new Aws.AutoScaling.ScheduleArgs
    {
        AutoscalingGroupName = foobarGroup.Name,
        DesiredCapacity = 0,
        EndTime = "2016-12-12T06:00:00Z",
        MaxSize = 1,
        MinSize = 0,
        ScheduledActionName = "foobar",
        StartTime = "2016-12-11T18:00:00Z",
    });
}

}

ScheduleArgs

ScheduleState

Back to top Copyright 2016-2020, Pulumi Corporation.