Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoscaling: set conflict between availability_zones and vpc_zone_identifier #12927

Merged
merged 5 commits into from Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions aws/resource_aws_autoscaling_group.go
Expand Up @@ -277,11 +277,12 @@ func resourceAwsAutoscalingGroup() *schema.Resource {
},

"vpc_zone_identifier": {
Type: schema.TypeSet,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
Type: schema.TypeSet,
Optional: true,
Computed: true,
ConflictsWith: []string{"availability_zones"},
Elem: &schema.Schema{Type: schema.TypeString},
Set: schema.HashString,
},

"termination_policies": {
Expand Down
87 changes: 0 additions & 87 deletions aws/resource_aws_autoscaling_group_test.go
Expand Up @@ -1342,39 +1342,6 @@ func TestAccAWSAutoScalingGroup_classicVpcZoneIdentifier(t *testing.T) {
})
}

func TestAccAWSAutoScalingGroup_emptyAvailabilityZones(t *testing.T) {
var group autoscaling.Group

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSAutoScalingGroupConfig_emptyAvailabilityZones,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.test", &group),
resource.TestCheckResourceAttr("aws_autoscaling_group.test", "availability_zones.#", "1"),
),
},
{
ResourceName: "aws_autoscaling_group.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"force_delete",
"initial_lifecycle_hook",
"name_prefix",
"tag",
"tags",
"wait_for_capacity_timeout",
"wait_for_elb_capacity",
},
},
},
})
}

func TestAccAWSAutoScalingGroup_launchTemplate(t *testing.T) {
var group autoscaling.Group

Expand Down Expand Up @@ -3367,7 +3334,6 @@ resource "aws_autoscaling_group" "test" {

availability_zones = ["us-west-2a"]
launch_configuration = "${aws_launch_configuration.test.name}"
vpc_zone_identifier = []
}

data "aws_ami" "test_ami" {
Expand All @@ -3386,59 +3352,6 @@ resource "aws_launch_configuration" "test" {
}
`

const testAccAWSAutoScalingGroupConfig_emptyAvailabilityZones = `
resource "aws_vpc" "test" {
cidr_block = "10.0.0.0/16"
tags = {
Name = "terraform-testacc-autoscaling-group-empty-azs"
}
}

data "aws_availability_zones" "available" {
# t2.micro is not supported in us-west-2d
blacklisted_zone_ids = ["usw2-az4"]
state = "available"

filter {
name = "opt-in-status"
values = ["opt-in-not-required"]
}
}

resource "aws_subnet" "test" {
availability_zone = "${data.aws_availability_zones.available.names[0]}"
vpc_id = "${aws_vpc.test.id}"
cidr_block = "10.0.0.0/16"
tags = {
Name = "tf-acc-autoscaling-group-empty-availability-zones"
}
}

resource "aws_autoscaling_group" "test" {
min_size = 0
max_size = 0

availability_zones = []
launch_configuration = "${aws_launch_configuration.test.name}"
vpc_zone_identifier = ["${aws_subnet.test.id}"]
}

data "aws_ami" "test_ami" {
most_recent = true
owners = ["amazon"]

filter {
name = "name"
values = ["amzn-ami-hvm-*-x86_64-gp2"]
}
}

resource "aws_launch_configuration" "test" {
image_id = "${data.aws_ami.test_ami.id}"
instance_type = "t2.micro"
}
`

const testAccAWSAutoScalingGroupConfig_withLaunchTemplate = `
data "aws_ami" "test_ami" {
most_recent = true
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/autoscaling_group.html.markdown
Expand Up @@ -168,7 +168,7 @@ The following arguments are supported:
* `max_size` - (Required) The maximum size of the auto scale group.
* `min_size` - (Required) The minimum size of the auto scale group.
(See also [Waiting for Capacity](#waiting-for-capacity) below.)
* `availability_zones` - (Required only for EC2-Classic) A list of one or more availability zones for the group. This parameter should not be specified when using `vpc_zone_identifier`.
* `availability_zones` - (Required only for EC2-Classic) A list of one or more availability zones for the group. This parameter conflicts with `vpc_zone_identifier`.
* `default_cooldown` - (Optional) The amount of time, in seconds, after a scaling activity completes before another scaling activity can start.
* `launch_configuration` - (Optional) The name of the launch configuration to use.
* `launch_template` - (Optional) Nested argument with Launch template specification to use to launch instances. Defined below.
Expand Down