From 9541c37ef4bf594308293bd40175b650ea3f5273 Mon Sep 17 00:00:00 2001 From: Trevor Pounds Date: Sat, 9 Jan 2016 15:15:57 -0800 Subject: [PATCH] Fix ELB availability zones and subnets read logic. --- builtin/providers/aws/resource_aws_elb.go | 4 ++-- builtin/providers/aws/resource_aws_elb_test.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index 23042aa5b..b25c7f5a6 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -338,7 +338,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { d.Set("dns_name", *lb.DNSName) d.Set("zone_id", *lb.CanonicalHostedZoneNameID) d.Set("internal", *lb.Scheme == "internal") - d.Set("availability_zones", lb.AvailabilityZones) + d.Set("availability_zones", flattenStringList(lb.AvailabilityZones)) d.Set("instances", flattenInstances(lb.Instances)) d.Set("listener", flattenListeners(lb.ListenerDescriptions)) d.Set("security_groups", lb.SecurityGroups) @@ -357,7 +357,7 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { } } } - d.Set("subnets", lb.Subnets) + d.Set("subnets", flattenStringList(lb.Subnets)) d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) d.Set("connection_draining", lbAttrs.ConnectionDraining.Enabled) d.Set("connection_draining_timeout", lbAttrs.ConnectionDraining.Timeout) diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index 83e947f93..168238ed8 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -29,12 +29,17 @@ func TestAccAWSELB_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), testAccCheckAWSELBAttributes(&conf), + resource.TestCheckResourceAttr( + "aws_elb.bar", "availability_zones.#", "3"), resource.TestCheckResourceAttr( "aws_elb.bar", "availability_zones.2487133097", "us-west-2a"), resource.TestCheckResourceAttr( "aws_elb.bar", "availability_zones.221770259", "us-west-2b"), resource.TestCheckResourceAttr( "aws_elb.bar", "availability_zones.2050015877", "us-west-2c"), + resource.TestCheckResourceAttr( + "aws_elb.bar", "subnets.#", "3"), + // NOTE: Subnet IDs are different across AWS accounts and cannot be checked. resource.TestCheckResourceAttr( "aws_elb.bar", "listener.206423021.instance_port", "8000"), resource.TestCheckResourceAttr(