diff --git a/aws/resource_aws_autoscaling_group.go b/aws/resource_aws_autoscaling_group.go index cd1499e5f81..e53de952395 100644 --- a/aws/resource_aws_autoscaling_group.go +++ b/aws/resource_aws_autoscaling_group.go @@ -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 diff --git a/aws/resource_aws_autoscaling_group_test.go b/aws/resource_aws_autoscaling_group_test.go index 8a898f700fb..46609211540 100644 --- a/aws/resource_aws_autoscaling_group_test.go +++ b/aws/resource_aws_autoscaling_group_test.go @@ -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" @@ -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" +} +`