diff --git a/builtin/providers/aws/resource_aws_elb.go b/builtin/providers/aws/resource_aws_elb.go index 91d523d3f363..ce69ff6ef73a 100644 --- a/builtin/providers/aws/resource_aws_elb.go +++ b/builtin/providers/aws/resource_aws_elb.go @@ -388,7 +388,9 @@ func resourceAwsElbRead(d *schema.ResourceData, meta interface{}) error { } } d.Set("subnets", flattenStringList(lb.Subnets)) - d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) + if lbAttrs.ConnectionSettings != nil { + d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) + } d.Set("connection_draining", lbAttrs.ConnectionDraining.Enabled) d.Set("connection_draining_timeout", lbAttrs.ConnectionDraining.Timeout) d.Set("cross_zone_load_balancing", lbAttrs.CrossZoneLoadBalancing.Enabled) diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index 763bd6a2ca4d..d39f76bff237 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -26,7 +26,7 @@ func TestAccAWSELB_basic(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -70,7 +70,7 @@ func TestAccAWSELB_fullCharacterRange(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: fmt.Sprintf(testAccAWSELBFullRangeOfCharacters, lbName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), @@ -93,14 +93,14 @@ func TestAccAWSELB_AccessLogs_enabled(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBAccessLogs, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), ), }, - resource.TestStep{ + { Config: testAccAWSELBAccessLogsOn(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), @@ -115,7 +115,7 @@ func TestAccAWSELB_AccessLogs_enabled(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBAccessLogs, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), @@ -138,14 +138,14 @@ func TestAccAWSELB_AccessLogs_disabled(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBAccessLogs, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), ), }, - resource.TestStep{ + { Config: testAccAWSELBAccessLogsDisabled(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), @@ -160,7 +160,7 @@ func TestAccAWSELB_AccessLogs_disabled(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBAccessLogs, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), @@ -182,7 +182,7 @@ func TestAccAWSELB_generatedName(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBGeneratedName, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.foo", &conf), @@ -203,7 +203,7 @@ func TestAccAWSELB_availabilityZones(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -218,7 +218,7 @@ func TestAccAWSELB_availabilityZones(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBConfig_AvailabilityZonesUpdate, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -244,7 +244,7 @@ func TestAccAWSELB_tags(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -254,7 +254,7 @@ func TestAccAWSELB_tags(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBConfig_TagUpdate, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -285,7 +285,7 @@ func TestAccAWSELB_iam_server_cert(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccELBIAMServerCertConfig( fmt.Sprintf("tf-acctest-%s", acctest.RandString(10))), Check: resource.ComposeTestCheckFunc( @@ -306,7 +306,7 @@ func TestAccAWSELB_swap_subnets(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig_subnets, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.ourapp", &conf), @@ -315,7 +315,7 @@ func TestAccAWSELB_swap_subnets(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBConfig_subnet_swap, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.ourapp", &conf), @@ -363,7 +363,7 @@ func TestAccAWSELB_InstanceAttaching(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -371,7 +371,7 @@ func TestAccAWSELB_InstanceAttaching(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigNewInstance, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -391,7 +391,7 @@ func TestAccAWSELBUpdate_Listener(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -401,7 +401,7 @@ func TestAccAWSELBUpdate_Listener(t *testing.T) { ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigListener_update, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -422,7 +422,7 @@ func TestAccAWSELB_HealthCheck(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfigHealthCheck, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -450,14 +450,14 @@ func TestAccAWSELBUpdate_HealthCheck(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfigHealthCheck, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "aws_elb.bar", "health_check.0.healthy_threshold", "5"), ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigHealthCheck_update, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -477,7 +477,7 @@ func TestAccAWSELB_Timeout(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfigIdleTimeout, Check: resource.ComposeTestCheckFunc( testAccCheckAWSELBExists("aws_elb.bar", &conf), @@ -497,7 +497,7 @@ func TestAccAWSELBUpdate_Timeout(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfigIdleTimeout, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -505,7 +505,7 @@ func TestAccAWSELBUpdate_Timeout(t *testing.T) { ), ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigIdleTimeout_update, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -524,7 +524,7 @@ func TestAccAWSELB_ConnectionDraining(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfigConnectionDraining, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -546,7 +546,7 @@ func TestAccAWSELBUpdate_ConnectionDraining(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfigConnectionDraining, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -557,7 +557,7 @@ func TestAccAWSELBUpdate_ConnectionDraining(t *testing.T) { ), ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigConnectionDraining_update_timeout, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -568,7 +568,7 @@ func TestAccAWSELBUpdate_ConnectionDraining(t *testing.T) { ), ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigConnectionDraining_update_disable, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( @@ -587,7 +587,7 @@ func TestAccAWSELB_SecurityGroups(t *testing.T) { Providers: testAccProviders, CheckDestroy: testAccCheckAWSELBDestroy, Steps: []resource.TestStep{ - resource.TestStep{ + { Config: testAccAWSELBConfig, Check: resource.ComposeTestCheckFunc( // ELBs get a default security group @@ -596,7 +596,7 @@ func TestAccAWSELB_SecurityGroups(t *testing.T) { ), ), }, - resource.TestStep{ + { Config: testAccAWSELBConfigSecurityGroups, Check: resource.ComposeTestCheckFunc( // Count should still be one as we swap in a custom security group