From e9d94bd213721dfa6c737bc9cea7e3f69a11283f Mon Sep 17 00:00:00 2001 From: Atsushi Ishibashi Date: Mon, 1 Jan 2018 23:24:41 +0900 Subject: [PATCH 1/2] Replace GetOk with GetOkExists --- aws/resource_aws_cloudtrail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_cloudtrail.go b/aws/resource_aws_cloudtrail.go index 5e347b8d156..78d6828f3cb 100644 --- a/aws/resource_aws_cloudtrail.go +++ b/aws/resource_aws_cloudtrail.go @@ -99,7 +99,7 @@ func resourceAwsCloudTrailCreate(d *schema.ResourceData, meta interface{}) error if v, ok := d.GetOk("cloud_watch_logs_role_arn"); ok { input.CloudWatchLogsRoleArn = aws.String(v.(string)) } - if v, ok := d.GetOk("include_global_service_events"); ok { + if v, ok := d.GetOkExists("include_global_service_events"); ok { input.IncludeGlobalServiceEvents = aws.Bool(v.(bool)) } if v, ok := d.GetOk("is_multi_region_trail"); ok { From 93d0b8fd254067f2c5ddc9598dfddcf070b595d0 Mon Sep 17 00:00:00 2001 From: Atsushi Ishibashi Date: Sat, 10 Feb 2018 17:29:57 +0900 Subject: [PATCH 2/2] update --- aws/resource_aws_cloudtrail_test.go | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/aws/resource_aws_cloudtrail_test.go b/aws/resource_aws_cloudtrail_test.go index 09c13190f59..2dd1c42c572 100644 --- a/aws/resource_aws_cloudtrail_test.go +++ b/aws/resource_aws_cloudtrail_test.go @@ -288,6 +288,26 @@ func testAccAWSCloudTrail_tags(t *testing.T) { }) } +func TestAccAWSCloudTrail_include_global_service_events(t *testing.T) { + var trail cloudtrail.Trail + cloudTrailRandInt := acctest.RandInt() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCloudTrailDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSCloudTrailConfig_include_global_service_events(cloudTrailRandInt), + Check: resource.ComposeTestCheckFunc( + testAccCheckCloudTrailExists("aws_cloudtrail.foobar", &trail), + resource.TestCheckResourceAttr("aws_cloudtrail.foobar", "include_global_service_events", "false"), + ), + }, + }, + }) +} + func testAccCheckCloudTrailExists(n string, trail *cloudtrail.Trail) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -937,6 +957,47 @@ POLICY } ` +func testAccAWSCloudTrailConfig_include_global_service_events(cloudTrailRandInt int) string { + return fmt.Sprintf(` +resource "aws_cloudtrail" "foobar" { + name = "tf-trail-foobar-%d" + s3_bucket_name = "${aws_s3_bucket.foo.id}" + include_global_service_events = false +} + +resource "aws_s3_bucket" "foo" { + bucket = "tf-test-trail-%d" + force_destroy = true + policy = <