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

Fix handling of vpc_zone_identifier for autoscaling groups in EC2 classic #1191

Merged
merged 1 commit into from
Jul 20, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion aws/resource_aws_autoscaling_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,12 @@ func resourceAwsAutoscalingGroupRead(d *schema.ResourceData, meta interface{}) e
d.Set("tag", autoscalingTagDescriptionsToSlice(g.Tags))
}

d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ","))
if len(*g.VPCZoneIdentifier) > 0 {
d.Set("vpc_zone_identifier", strings.Split(*g.VPCZoneIdentifier, ","))
} else {
d.Set("vpc_zone_identifier", []string{})
}

d.Set("protect_from_scale_in", g.NewInstancesProtectedFromScaleIn)

// If no termination polices are explicitly configured and the upstream state
Expand Down
36 changes: 36 additions & 0 deletions aws/resource_aws_autoscaling_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,26 @@ func testAccCheckAWSALBTargetGroupHealthy(res *elbv2.TargetGroup) resource.TestC
}
}

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

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
IDRefreshName: "aws_autoscaling_group.test",
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSAutoScalingGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSAutoScalingGroupConfig_classicVpcZoneIdentifier,
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.test", &group),
resource.TestCheckResourceAttr("aws_autoscaling_group.test", "vpc_zone_identifier.#", "0"),
),
},
},
})
}

const testAccAWSAutoScalingGroupConfig_autoGeneratedName = `
resource "aws_launch_configuration" "foobar" {
image_id = "ami-21f78e11"
Expand Down Expand Up @@ -1790,3 +1810,19 @@ resource "aws_autoscaling_group" "bar" {
}
`, name, name)
}

const testAccAWSAutoScalingGroupConfig_classicVpcZoneIdentifier = `
resource "aws_autoscaling_group" "test" {
min_size = 0
max_size = 0
availability_zones = ["us-west-2a"]
launch_configuration = "${aws_launch_configuration.test.name}"
vpc_zone_identifier = []
}
resource "aws_launch_configuration" "test" {
image_id = "ami-21f78e11"
instance_type = "t1.micro"
}
`