From 568483c2a85a72e4f740b910141dcd0f2a5cf4bc Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 01/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 5273c73ef1b1f4f8fb03893c31be4658fdee0df6 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 02/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From f2c5be9e12473a0ca4757728b16c0f4d00a468e7 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 03/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 1e48317b9e5c9e3b662ba87da88c07f08337c672 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 04/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 98e41cebc70532c5911392c985f9d9b170d651ac Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 05/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 598e773dad9831dca48bc0da716712a7469a2e08 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 06/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 15ec17cb671c2a026440bb71343a6c9e23cd8fd8 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 07/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From bc225f5f51b8606203ef44fe3cfa61aeccf828e1 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 08/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 4a0d439eb123986b1e11f28760fb7946494c5cbc Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 09/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 6de2c69520d45caf911ac0ad04bfb57228779f98 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 10/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 4b02fb8770a71d593702e1edd0ae2fd4a88fb955 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 11/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 2cec2e19503bafd46a4b281f3d3711365751b1cb Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 12/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 00dfa0f3b9f29e4e004c4d1fa1ccebd20aa6c79a Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 13/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 8d235f493cadac7d0314adb021bcd8fa268f8b8f Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 14/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 91e1233778aee461d02d02d94e915f7db12dc065 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 15/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From bdc81526b567af5e20a758572a5c0cb1750b7c08 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 16/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 05b240f4971fa924d677adcec1a26804dee5dc90 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 17/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 03029dfaded01a3648f22756af5faad80009337e Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 18/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From d0e44c26ec573aa18e4a3a77111e93c3b14884b7 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 19/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 38111b28db53016972f4ce0b2733fc26503eb2ac Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 20/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 8a438a587f98b4caea33f32fd1fe2bea1ac96f8c Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 21/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 514ec73338c25dd0e526c7bd24f392f864093622 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 22/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 3a1bb6e1317e903669901f35ce8ed67340fc1f69 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 23/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 37a7e378b4835bca8d4912f8c05882089060f0d3 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 24/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From f50d10eb82ec2cd178dc4a40baee5c69330ac11e Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 25/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 2d998a6ad1363848ae8da62bc47066669c3da226 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 26/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From f3142cb8d44836ea36db9a91dc24eb1ada035352 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 27/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 8c765d82918ce332485db40d3b58653952790f6e Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 28/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From bb2cc6c1f9c4494b6b752c141afc7351168693e4 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 29/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 7075f84313c436930ba65406f1055ce2f8723479 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 30/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 94bf75b5fe9e2fb67dfe46c2a70feffe94ebb78d Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 31/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 00f5a58a8f8a79ddcde255e84bcffdda28dca641 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 32/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 5417d9c4890327f7db7d48358d605a4888c1318c Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 33/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From e784c3b40048b87922ffb916225993f3d30dfc50 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 34/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 5b72f621b88b2f248ef48d0e1dbde695a80facd9 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 35/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From be2dae42e3970d8f8e25ec96a41028c923ca51a8 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 36/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From fb49eab2a5014b11968ab2bb4c45d6ce6414ac65 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 37/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 0c9c79a1513d32f76ce1abb60d63b23d5e61858c Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 38/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 5eee7750b07b4159c9d6e1a832edeac0b67d9ab1 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 39/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 330efeccbec5f186d3dc5dfa1a0fd862756f40cd Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 40/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 675d548ac0d2be56700fdec81caeb40d72612f5f Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 41/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 70780c29c89508dfe4c6acba95831cfc5cdab905 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 42/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 1b1da85a3c890df3dfba7c4516e8ef3e14b6f236 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 43/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From ba6b5e045fd32fba5171a05508ead59452639bcc Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 44/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 604dfee4cb4f3f1f5f160cfbf42e278127cf8620 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 45/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 103ac1699d8fe79ae73d9a44d11322978c0e1a33 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 46/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 47c55340cd20518d6a492b3602f6ed1d7bb1d644 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 47/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 710a1e18e5476e9edbc2d4a363d3a3817235a3b0 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 48/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 25ad2900ec18e0f36309661d70f36ee38247a2d5 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 49/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From abea1ec23e7a374a42fd97841313bc4c78b3e445 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 50/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From e62a9266507cfb8eb2171da69b30c77f21e9e495 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 51/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From fb77f7e99edcc5ef68c9e53484ccc3a0f58721f3 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 52/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 6c24ed90ecd2f7ef432bf87c9351d681ed14ecea Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 53/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From a8109ad96ba3dfe6fdd9accbf46d138ca2572d6e Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 54/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From f130f7486579a17c9c3d4ed70b99b01c8c0c7eb6 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 55/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From e27dc7c93ffd066c9b046414ad8a31b3a44f2bbe Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 56/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 718cfb9a74ef66c0ca2a2dc0afcba50bc45532de Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 57/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 7680fb4ee35d174cbd2ae2b9c0bc57699c228f65 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 58/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From c427fd671fdcee9aec833fc79de2f66eb100663a Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 59/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From c4cee221f501692fad49e09d3a4a9060ce1c74ed Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 60/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From d5b61ff0630a72ca6552f5a9626a59b8ea4f7104 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 61/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From f4cba16170f0b7898c682893ba16fdac2f4081fd Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 62/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 9cbf79242dfd59bb09e2dabf5499070d3cec9ebb Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 63/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From e3de6361cfc6b0273a6fef1dc4773c6944d82d51 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 64/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 3e55b93725c4aa54cb38fabf13cbcabcd67951d4 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 65/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 949263cbe05d45724dc05297309532db9762d868 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 66/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From da27901561f07bb2dcaf337f2dbe6298769bf081 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 67/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From b0001c1918f72f40599ce9db4f9d39da7d4ee9c3 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 68/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 17720db5e8a2e688fe6b8ffa374b291cb811cbf8 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 69/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 8338f0150f103c353663b152a8749a8d89d5007f Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 70/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 0bb94658650921b732ddfcd9dd2972cfe875b042 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 71/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 89162b3ddfa751d867412f4cb2d5d707e4b13459 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 72/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 47800b9d533d172627ba8b410a43bcd84b944a85 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 73/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 419bef83eba81b244f9899752d275c4ece94617e Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 74/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From e4c474df935ce2a118b784854287f4220ef5a377 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 75/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 7c79b3bfdc17c2e9ce7d4812ab34a18af26887c0 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 76/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From ca140808934e5fd217376871aec59aa0da52e8b5 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 77/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 40e3fb9a35a7657cf5031f863df1874345fa71b8 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 78/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 7d6c499121d402811b5f7b7734428c141305792d Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 79/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From ff5d36fb5cc9e24f5018c55f4e6997003a7335fd Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 80/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 8201dff6df5f7cd6fc60893187c213c13f4c057e Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 81/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 1dc05d52a040c47d89bfa8a3a5d0170190d76d99 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 82/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 251522c61764f6dbe76d2fdf0873d858b92c2488 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 83/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 1a9362ea1c891ecf7a9209a28382a98d3ea82b33 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 84/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From ffa817db256e47cc2bd8108df85df7108f375794 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 85/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 29a93d9800bfd59120f96d0ad63f6d078f3d550a Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 86/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 9f4ebbc3d47dbf2f3c60969fa9a2911c427626f3 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 87/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 063a82afb1f9df95d7310110a2e76608ff357460 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 88/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From e39aff0958de9b2e7e449eecc3745c69b229fbd2 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 89/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From bed33fb085119f4f93eb53b19aa2831f39c5a8fc Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 90/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 4900a69c332cdb90f53700afd0acf21c0bc0dc9f Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 91/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 33cc32a76074d03ece014303f6aeaf9f967dd2c9 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 92/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 5dc41d9b79ab6079a75e4415d9c7d239c59f5816 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 93/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From feb3ae7988d4b7c6b7020369bfde5252a4fd7a90 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 94/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 50554ffe539b967a14f79e255b43897a1a73f268 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 22 Apr 2021 22:15:51 +0530 Subject: [PATCH 95/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 ++++++++++++++++++++- aws/resource_aws_securityhub_test.go | 1 + 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index 20ceb386108..cd2ebb034c7 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index 23862a53ca4..d2a9f2d02da 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,6 +37,32 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } +func testAccAWSSecurityHubMember_email(t *testing.T) { + var member securityhub.Member + resourceName := "aws_securityhub_member.example" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSSecurityHubMemberExists(resourceName, &member), + resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -125,7 +151,18 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { + return fmt.Sprintf(` +resource "aws_securityhub_account" "example" {} + +resource "aws_securityhub_member" "example" { + depends_on = [aws_securityhub_account.example] + account_id = "%s" +} +`, accountId) +} + +func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index ee4601b8d31..20f4ff6e19b 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,6 +11,7 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, + "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From 361eaf4bd395fa861cb7d348c6979f0a5f730c38 Mon Sep 17 00:00:00 2001 From: nikhil Date: Sun, 25 Apr 2021 12:36:05 +0530 Subject: [PATCH 96/99] f/aws_securityhub_member: email is optional variable --- aws/resource_aws_securityhub_member.go | 2 +- aws/resource_aws_securityhub_member_test.go | 41 +-------------------- aws/resource_aws_securityhub_test.go | 1 - 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/aws/resource_aws_securityhub_member.go b/aws/resource_aws_securityhub_member.go index cd2ebb034c7..20ceb386108 100644 --- a/aws/resource_aws_securityhub_member.go +++ b/aws/resource_aws_securityhub_member.go @@ -38,7 +38,7 @@ func resourceAwsSecurityHubMember() *schema.Resource { }, "email": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, }, "invite": { diff --git a/aws/resource_aws_securityhub_member_test.go b/aws/resource_aws_securityhub_member_test.go index d2a9f2d02da..23862a53ca4 100644 --- a/aws/resource_aws_securityhub_member_test.go +++ b/aws/resource_aws_securityhub_member_test.go @@ -23,7 +23,7 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSSecurityHubMemberConfig_basic("111111111111"), + Config: testAccAWSSecurityHubMemberConfig_basic("111111111111", "example@example.com"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSSecurityHubMemberExists(resourceName, &member), ), @@ -37,32 +37,6 @@ func testAccAWSSecurityHubMember_basic(t *testing.T) { }) } -func testAccAWSSecurityHubMember_email(t *testing.T) { - var member securityhub.Member - resourceName := "aws_securityhub_member.example" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ErrorCheck: testAccErrorCheck(t, securityhub.EndpointsID), - Providers: testAccProviders, - CheckDestroy: testAccCheckAWSSecurityHubMemberDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAWSSecurityHubMemberConfig_email("111111111111", "example@example.com"), - Check: resource.ComposeTestCheckFunc( - testAccCheckAWSSecurityHubMemberExists(resourceName, &member), - resource.TestCheckResourceAttr(resourceName, "email", "example@example.com"), - ), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccAWSSecurityHubMember_invite(t *testing.T) { var member securityhub.Member resourceName := "aws_securityhub_member.example" @@ -151,18 +125,7 @@ func testAccCheckAWSSecurityHubMemberDestroy(s *terraform.State) error { return nil } -func testAccAWSSecurityHubMemberConfig_basic(accountId string) string { - return fmt.Sprintf(` -resource "aws_securityhub_account" "example" {} - -resource "aws_securityhub_member" "example" { - depends_on = [aws_securityhub_account.example] - account_id = "%s" -} -`, accountId) -} - -func testAccAWSSecurityHubMemberConfig_email(accountId, email string) string { +func testAccAWSSecurityHubMemberConfig_basic(accountId, email string) string { return fmt.Sprintf(` resource "aws_securityhub_account" "example" {} diff --git a/aws/resource_aws_securityhub_test.go b/aws/resource_aws_securityhub_test.go index 20f4ff6e19b..ee4601b8d31 100644 --- a/aws/resource_aws_securityhub_test.go +++ b/aws/resource_aws_securityhub_test.go @@ -11,7 +11,6 @@ func TestAccAWSSecurityHub_serial(t *testing.T) { }, "Member": { "basic": testAccAWSSecurityHubMember_basic, - "email": testAccAWSSecurityHubMember_email, "invite": testAccAWSSecurityHubMember_invite, }, "ActionTarget": { From c1d952db314a1e9b5b4508a23a3ad185514ac2d5 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 13 May 2021 20:26:16 +0530 Subject: [PATCH 97/99] aws_pinpoint_email_channel: Role arn is optional --- aws/resource_aws_pinpoint_email_channel.go | 7 ++- ...esource_aws_pinpoint_email_channel_test.go | 50 +++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_pinpoint_email_channel.go b/aws/resource_aws_pinpoint_email_channel.go index c87d53f67b1..d0988a2ba68 100644 --- a/aws/resource_aws_pinpoint_email_channel.go +++ b/aws/resource_aws_pinpoint_email_channel.go @@ -46,7 +46,7 @@ func resourceAwsPinpointEmailChannel() *schema.Resource { }, "role_arn": { Type: schema.TypeString, - Required: true, + Optional: true, ValidateFunc: validateArn, }, "messages_per_second": { @@ -67,7 +67,10 @@ func resourceAwsPinpointEmailChannelUpsert(d *schema.ResourceData, meta interfac params.Enabled = aws.Bool(d.Get("enabled").(bool)) params.FromAddress = aws.String(d.Get("from_address").(string)) params.Identity = aws.String(d.Get("identity").(string)) - params.RoleArn = aws.String(d.Get("role_arn").(string)) + + if v, ok := d.GetOk("role_arn"); ok { + params.RoleArn = aws.String(v.(string)) + } if v, ok := d.GetOk("configuration_set"); ok { params.ConfigurationSet = aws.String(v.(string)) diff --git a/aws/resource_aws_pinpoint_email_channel_test.go b/aws/resource_aws_pinpoint_email_channel_test.go index 39718eb837d..8aa78756a02 100644 --- a/aws/resource_aws_pinpoint_email_channel_test.go +++ b/aws/resource_aws_pinpoint_email_channel_test.go @@ -74,6 +74,34 @@ func TestAccAWSPinpointEmailChannel_configurationSet(t *testing.T) { }, }) } + +func TestAccAWSPinpointEmailChannel_noRole(t *testing.T) { + var channel pinpoint.EmailChannelResponse + resourceName := "aws_pinpoint_email_channel.test" + rName := acctest.RandomWithPrefix("tf-acc-test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t); testAccPreCheckAWSPinpointApp(t) }, + ErrorCheck: testAccErrorCheck(t, pinpoint.EndpointsID), + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSPinpointEmailChannelDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSPinpointEmailChannelConfigNoRole("user@example.com", rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSPinpointEmailChannelExists(resourceName, &channel), + resource.TestCheckResourceAttrPair(resourceName, "configuration_set", "aws_ses_configuration_set.test", "arn"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAWSPinpointEmailChannel_disappears(t *testing.T) { var channel pinpoint.EmailChannelResponse resourceName := "aws_pinpoint_email_channel.test" @@ -244,6 +272,28 @@ EOF `, fromAddress, rName) } +func testAccAWSPinpointEmailChannelConfigNoRole(fromAddress, rName string) string { + return fmt.Sprintf(` +resource "aws_pinpoint_app" "test" {} + +resource "aws_ses_configuration_set" "test" { + name = %[2]q +} + +resource "aws_pinpoint_email_channel" "test" { + application_id = aws_pinpoint_app.test.application_id + enabled = "false" + from_address = %[1]q + identity = aws_ses_domain_identity.test.arn + configuration_set = aws_ses_configuration_set.test.arn +} + +resource "aws_ses_domain_identity" "test" { + domain = "example.com" +} +`, fromAddress, rName) +} + func testAccCheckAWSPinpointEmailChannelDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).pinpointconn From 143a217583af40e47c1a50440122e1ae0deb0165 Mon Sep 17 00:00:00 2001 From: nikhil Date: Thu, 13 May 2021 20:28:24 +0530 Subject: [PATCH 98/99] aws_pinpoint_email_channel: Role arn is optional --- website/docs/r/pinpoint_email_channel.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/pinpoint_email_channel.markdown b/website/docs/r/pinpoint_email_channel.markdown index a96011ea233..95a43627952 100644 --- a/website/docs/r/pinpoint_email_channel.markdown +++ b/website/docs/r/pinpoint_email_channel.markdown @@ -76,7 +76,7 @@ The following arguments are supported: * `configuration_set` - (Optional) The ARN of the Amazon SES configuration set that you want to apply to messages that you send through the channel. * `from_address` - (Required) The email address used to send emails from. * `identity` - (Required) The ARN of an identity verified with SES. -* `role_arn` - (Required) The ARN of an IAM Role used to submit events to Mobile Analytics' event ingestion service. +* `role_arn` - (Optional) The ARN of an IAM Role used to submit events to Mobile Analytics' event ingestion service. ## Attributes Reference From 2dceb8a1715de8d2e928cdd27b8faeeeac0c52a1 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 14 May 2021 11:19:44 -0400 Subject: [PATCH 99/99] Add CHANGELOG entry. --- .changelog/19361.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/19361.txt diff --git a/.changelog/19361.txt b/.changelog/19361.txt new file mode 100644 index 00000000000..2233e399f0d --- /dev/null +++ b/.changelog/19361.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_pinpoint_email_channel: `role_arn` argument is optional +``` \ No newline at end of file