2014-07-24 05:34:59 +02:00
|
|
|
---
|
|
|
|
layout: "aws"
|
|
|
|
page_title: "AWS: aws_autoscaling_group"
|
2015-05-30 16:42:24 +02:00
|
|
|
sidebar_current: "docs-aws-resource-autoscaling-group"
|
2014-10-22 05:21:56 +02:00
|
|
|
description: |-
|
|
|
|
Provides an AutoScaling Group resource.
|
2014-07-24 05:34:59 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
# aws\_autoscaling\_group
|
|
|
|
|
|
|
|
Provides an AutoScaling Group resource.
|
|
|
|
|
|
|
|
## Example Usage
|
|
|
|
|
|
|
|
```
|
2015-11-02 16:44:29 +01:00
|
|
|
resource "aws_placement_group" "test" {
|
|
|
|
name = "test"
|
|
|
|
strategy = "cluster"
|
|
|
|
}
|
|
|
|
|
2014-07-24 05:34:59 +02:00
|
|
|
resource "aws_autoscaling_group" "bar" {
|
|
|
|
availability_zones = ["us-east-1a"]
|
|
|
|
name = "foobar3-terraform-test"
|
|
|
|
max_size = 5
|
|
|
|
min_size = 2
|
|
|
|
health_check_grace_period = 300
|
|
|
|
health_check_type = "ELB"
|
2014-07-29 08:51:24 +02:00
|
|
|
desired_capacity = 4
|
2014-07-24 05:34:59 +02:00
|
|
|
force_delete = true
|
2015-11-02 16:44:29 +01:00
|
|
|
placement_group = "${aws_placement_group.test.id}"
|
2014-07-24 05:34:59 +02:00
|
|
|
launch_configuration = "${aws_launch_configuration.foobar.name}"
|
2015-03-03 00:40:47 +01:00
|
|
|
|
|
|
|
tag {
|
|
|
|
key = "foo"
|
|
|
|
value = "bar"
|
|
|
|
propagate_at_launch = true
|
|
|
|
}
|
|
|
|
tag {
|
|
|
|
key = "lorem"
|
|
|
|
value = "ipsum"
|
|
|
|
propagate_at_launch = false
|
|
|
|
}
|
2014-07-24 05:34:59 +02:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Argument Reference
|
|
|
|
|
|
|
|
The following arguments are supported:
|
|
|
|
|
2015-10-31 10:24:46 +01:00
|
|
|
* `name` - (Optional) The name of the auto scale group. By default generated by terraform.
|
2014-07-24 05:34:59 +02:00
|
|
|
* `max_size` - (Required) The maximum size of the auto scale group.
|
2015-05-14 19:45:21 +02:00
|
|
|
* `min_size` - (Required) The minimum size of the auto scale group.
|
|
|
|
(See also [Waiting for Capacity](#waiting-for-capacity) below.)
|
2015-07-14 17:24:16 +02:00
|
|
|
* `availability_zones` - (Optional) A list of AZs to launch resources in.
|
|
|
|
Required only if you do not specify any `vpc_zone_identifier`
|
2015-08-17 16:24:25 +02:00
|
|
|
* `launch_configuration` - (Required) The name of the launch configuration to use.
|
2015-11-02 16:44:29 +01:00
|
|
|
* `health_check_grace_period` - (Optional) Time after instance comes into service before checking health.
|
2014-07-24 05:34:59 +02:00
|
|
|
* `health_check_type` - (Optional) "EC2" or "ELB". Controls how health checking is done.
|
2015-05-07 01:34:20 +02:00
|
|
|
* `desired_capacity` - (Optional) The number of Amazon EC2 instances that
|
2015-05-14 19:45:21 +02:00
|
|
|
should be running in the group. (See also [Waiting for
|
|
|
|
Capacity](#waiting-for-capacity) below.)
|
|
|
|
* `min_elb_capacity` - (Optional) Setting this will cause Terraform to wait
|
|
|
|
for this number of healthy instances all attached load balancers.
|
|
|
|
(See also [Waiting for Capacity](#waiting-for-capacity) below.)
|
2014-07-24 05:34:59 +02:00
|
|
|
* `force_delete` - (Optional) Allows deleting the autoscaling group without waiting
|
2015-10-12 22:50:07 +02:00
|
|
|
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, Terraform
|
|
|
|
drains all the instances before deleting the group. This bypasses that
|
|
|
|
behavior and potentially leaves resources dangling.
|
2015-01-14 18:28:25 +01:00
|
|
|
* `load_balancers` (Optional) A list of load balancer names to add to the autoscaling
|
2014-08-20 19:40:43 +02:00
|
|
|
group names.
|
2015-01-14 18:28:25 +01:00
|
|
|
* `vpc_zone_identifier` (Optional) A list of subnet IDs to launch resources in.
|
|
|
|
* `termination_policies` (Optional) A list of policies to decide how the instances in the auto scale group should be terminated.
|
2015-03-03 00:40:47 +01:00
|
|
|
* `tag` (Optional) A list of tag blocks. Tags documented below.
|
2015-11-02 16:44:29 +01:00
|
|
|
* `placement_group` (Optional) The name of the placement group into which you'll launch your instances, if any.
|
2015-09-08 20:15:30 +02:00
|
|
|
* `wait_for_capacity_timeout` (Default: "10m") A maximum
|
|
|
|
[duration](https://golang.org/pkg/time/#ParseDuration) that Terraform should
|
|
|
|
wait for ASG instances to be healthy before timing out. (See also [Waiting
|
|
|
|
for Capacity](#waiting-for-capacity) below.) Setting this to "0" causes
|
|
|
|
Terraform to skip all Capacity Waiting behavior.
|
2015-03-03 00:40:47 +01:00
|
|
|
|
|
|
|
Tags support the following:
|
|
|
|
|
|
|
|
* `key` - (Required) Key
|
|
|
|
* `value` - (Required) Value
|
|
|
|
* `propagate_at_launch` - (Required) Enables propagation of the tag to
|
|
|
|
Amazon EC2 instances launched via this ASG
|
2014-07-24 05:34:59 +02:00
|
|
|
|
|
|
|
## Attributes Reference
|
|
|
|
|
|
|
|
The following attributes are exported:
|
|
|
|
|
|
|
|
* `id` - The autoscaling group name.
|
|
|
|
* `availability_zones` - The availability zones of the autoscale group.
|
|
|
|
* `min_size` - The minimum size of the autoscale group
|
|
|
|
* `max_size` - The maximum size of the autoscale group
|
|
|
|
* `default_cooldown` - Time between a scaling activity and the succeeding scaling activity.
|
|
|
|
* `name` - The name of the autoscale group
|
|
|
|
* `health_check_grace_period` - Time after instance comes into service before checking health.
|
|
|
|
* `health_check_type` - "EC2" or "ELB". Controls how health checking is done.
|
2014-07-29 08:51:24 +02:00
|
|
|
* `desired_capacity` -The number of Amazon EC2 instances that should be running in the group.
|
2014-07-24 05:34:59 +02:00
|
|
|
* `launch_configuration` - The launch configuration of the autoscale group
|
|
|
|
* `vpc_zone_identifier` - The VPC zone identifier
|
2014-08-20 19:40:43 +02:00
|
|
|
* `load_balancers` (Optional) The load balancer names associated with the
|
|
|
|
autoscaling group.
|
2015-09-28 11:51:36 +02:00
|
|
|
|
|
|
|
~> **NOTE:** When using `ELB` as the health_check_type, `health_check_grace_period` is required.
|
2015-05-14 19:45:21 +02:00
|
|
|
|
|
|
|
<a id="waiting-for-capacity"></a>
|
|
|
|
## 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.
|
|
|
|
|
|
|
|
Terraform provides two mechanisms to help consistently manage ASG scale up
|
|
|
|
time across dependent resources.
|
|
|
|
|
|
|
|
#### Waiting for ASG Capacity
|
|
|
|
|
|
|
|
The first is default behavior. Terraform waits after ASG creation for
|
|
|
|
`min_size` (or `desired_capacity`, if specified) healthy instances to show up
|
|
|
|
in the ASG before continuing.
|
|
|
|
|
|
|
|
Terraform considers an instance "healthy" when the ASG reports `HealthStatus:
|
|
|
|
"Healthy"` and `LifecycleState: "InService"`. See the [AWS AutoScaling
|
|
|
|
Docs](https://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/AutoScalingGroupLifecycle.html)
|
|
|
|
for more information on an ASG's lifecycle.
|
|
|
|
|
2015-09-08 20:15:30 +02:00
|
|
|
Terraform 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.
|
2015-05-14 19:45:21 +02:00
|
|
|
|
|
|
|
#### Waiting for ELB Capacity
|
|
|
|
|
|
|
|
The second mechanism is optional, and affects ASGs with attached Load
|
|
|
|
Balancers. If `min_elb_capacity` is set, Terraform will wait for that number of
|
|
|
|
Instances to be `"InService"` in all attached `load_balancers`. This can be
|
|
|
|
used to ensure that service is being provided before Terraform moves on.
|
|
|
|
|
2015-09-08 20:15:30 +02:00
|
|
|
As with ASG Capacity, Terraform will wait for up to `wait_for_capacity_timeout`
|
|
|
|
(for `"InService"` instances. 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](https://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/elb-troubleshooting.html)
|
2015-05-14 19:45:21 +02:00
|
|
|
for more information.
|