diff --git a/builtin/providers/aws/resource_aws_alb.go b/builtin/providers/aws/resource_aws_alb.go index da26ce49b..757f82165 100644 --- a/builtin/providers/aws/resource_aws_alb.go +++ b/builtin/providers/aws/resource_aws_alb.go @@ -88,6 +88,11 @@ func resourceAwsAlb() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "enabled": &schema.Schema{ + Type: schema.TypeBool, + Optional: true, + Default: true, + }, }, }, }, @@ -229,6 +234,8 @@ func resourceAwsAlbRead(d *schema.ResourceData, meta interface{}) error { accessLogMap := map[string]interface{}{} for _, attr := range attributesResp.Attributes { switch *attr.Key { + case "access_logs.s3.enabled": + accessLogMap["enabled"] = *attr.Value case "access_logs.s3.bucket": accessLogMap["bucket"] = *attr.Value case "access_logs.s3.prefix": @@ -276,7 +283,7 @@ func resourceAwsAlbUpdate(d *schema.ResourceData, meta interface{}) error { attributes = append(attributes, &elbv2.LoadBalancerAttribute{ Key: aws.String("access_logs.s3.enabled"), - Value: aws.String("true"), + Value: aws.String(strconv.FormatBool(log["enabled"].(bool))), }, &elbv2.LoadBalancerAttribute{ Key: aws.String("access_logs.s3.bucket"), diff --git a/builtin/providers/aws/resource_aws_alb_test.go b/builtin/providers/aws/resource_aws_alb_test.go index 168eda6c1..ad45f86da 100644 --- a/builtin/providers/aws/resource_aws_alb_test.go +++ b/builtin/providers/aws/resource_aws_alb_test.go @@ -232,6 +232,7 @@ func TestAccAWSALB_accesslogs(t *testing.T) { resource.TestCheckResourceAttr("aws_alb.alb_test", "access_logs.#", "1"), resource.TestCheckResourceAttr("aws_alb.alb_test", "access_logs.0.bucket", bucketName), resource.TestCheckResourceAttr("aws_alb.alb_test", "access_logs.0.prefix", "testAccAWSALBConfig_accessLogs"), + resource.TestCheckResourceAttr("aws_alb.alb_test", "access_logs.0.enabled", "true"), resource.TestCheckResourceAttrSet("aws_alb.alb_test", "arn"), ), }, @@ -582,6 +583,7 @@ func testAccAWSALBConfig_accessLogs(albName, bucketName string) string { access_logs { bucket = "${aws_s3_bucket.logs.bucket}" prefix = "${var.bucket_prefix}" + enabled = "${var.enabled}" } tags { diff --git a/website/source/docs/providers/aws/r/alb.html.markdown b/website/source/docs/providers/aws/r/alb.html.markdown index 6d7a2358a..f0976e08b 100644 --- a/website/source/docs/providers/aws/r/alb.html.markdown +++ b/website/source/docs/providers/aws/r/alb.html.markdown @@ -54,6 +54,7 @@ Access Logs (`access_logs`) support the following: * `bucket` - (Required) The S3 bucket name to store the logs in. * `prefix` - (Optional) The S3 bucket prefix. Logs are stored in the root if not configured. +* `enabled` = (Optional) Boolean to enable / disable `access_logs`. Default is `true` ## Attributes Reference