From c963793f3d02546c841850c96a564e1f8a255529 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Thu, 15 Jan 2015 10:43:26 +0200 Subject: [PATCH 1/3] providers/aws: elb subnet change should not force a new resource --- builtin/providers/aws/resource_aws_elb.go | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index 11d9bb7b7..e1f90900b 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -74,7 +74,6 @@ func resourceAwsElb() *schema.Resource { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, - ForceNew: true, Computed: true, Set: func(v interface{}) int { return hashcode.String(v.(string)) From cedf3a9415b11e5751e6c91bcc19e97a912410fd Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Thu, 15 Jan 2015 15:55:25 +0200 Subject: [PATCH 2/3] providers/aws: elb subnet change acceptance test add listeners add orig subnet --- .../providers/aws/resource_aws_elb_test.go | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index cf14613c9..1fa601c34 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -88,6 +88,42 @@ func TestAccAWSELB_InstanceAttaching(t *testing.T) { }) } +func TestAccAWSELB_AddSubnet(t *testing.T) { + var conf elb.LoadBalancer + + testCheckSubnetsAdded := func(count int) resource.TestCheckFunc { + return func(*terraform.State) error { + if len(conf.Subnets) != count { + return fmt.Errorf("subnet count does not match") + } + return nil + } + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSELBDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSELBConfigVPC, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSELBExists("aws_elb.bar", &conf), + testAccCheckAWSELBAttributes(&conf), + ), + }, + + resource.TestStep{ + Config: testAccAWSELBAddSubnets, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSELBExists("aws_elb.bar", &conf), + testCheckSubnetsAdded(2), + ), + }, + }, + }) +} + func TestAccAWSELB_HealthCheck(t *testing.T) { var conf elb.LoadBalancer @@ -287,6 +323,64 @@ resource "aws_instance" "foo" { instance_type = "t1.micro" } ` +const testAccAWSELBConfigVPC = ` +resource "aws_elb" "bar" { + vpc_id = "${aws_vpc.foobar.id}" + name = "foobar-terraform-test" + availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] + + listener { + instance_port = 8000 + instance_protocol = "http" + lb_port = 80 + lb_protocol = "http" + } + + subnets = ["${aws_subnet.baz.id}"] + +} + +resource "aws_subnet.baz" { + vpc_id = "${aws_vpc.foobar.id}" + cidr_block = "10.0.69.0/24" +} + +resource "aws_vpc" "foobar" { + cidr_block = "10.0.0.0/16" +} +` + +const testAccAWSELBAddSubnets = ` +resource "aws_elb" "bar" { + vpc_id = "${aws_vpc.foobar.id}" + name = "foobar-terraform-test" + availability_zones = ["us-west-2a", "us-west-2b", "us-west-2c"] + + listener { + instance_port = 8000 + instance_protocol = "http" + lb_port = 80 + lb_protocol = "http" + } + + subnets = ["${aws_subnet.baz.id}", + "${aws_subnet.foo.id}"] +} + +resource "aws_subnet.foo" { + vpc_id = "${aws_vpc.foobar.id}" + cidr_block = "10.0.68.0/24" +} + +resource "aws_subnet.baz" { + vpc_id = "${aws_vpc.foobar.id}" + cidr_block = "10.0.69.0/24" +} + +resource "aws_vpc" "foobar" { + cidr_block = "10.0.0.0/16" +} +` const testAccAWSELBConfigListenerSSLCertificateId = ` resource "aws_elb" "bar" { From a49f1b5dd892267bd1d3b79a19302d40fe698f32 Mon Sep 17 00:00:00 2001 From: Panagiotis Moustafellos Date: Fri, 16 Jan 2015 16:07:55 +0200 Subject: [PATCH 3/3] epic typo --- builtin/providers/aws/resource_aws_elb_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index 1fa601c34..cb5be7291 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -340,7 +340,7 @@ resource "aws_elb" "bar" { } -resource "aws_subnet.baz" { +resource "aws_subnet" "baz" { vpc_id = "${aws_vpc.foobar.id}" cidr_block = "10.0.69.0/24" } @@ -367,12 +367,12 @@ resource "aws_elb" "bar" { "${aws_subnet.foo.id}"] } -resource "aws_subnet.foo" { +resource "aws_subnet" "foo" { vpc_id = "${aws_vpc.foobar.id}" cidr_block = "10.0.68.0/24" } -resource "aws_subnet.baz" { +resource "aws_subnet" "baz" { vpc_id = "${aws_vpc.foobar.id}" cidr_block = "10.0.69.0/24" }