Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows enabling support of tag policies #11535

Merged
merged 8 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aws/resource_aws_organizations_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func resourceAwsOrganizationsOrganization() *schema.Resource {
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
organizations.PolicyTypeServiceControlPolicy,
organizations.PolicyTypeTagPolicy,
nikolaifa marked this conversation as resolved.
Show resolved Hide resolved
}, false),
},
},
Expand Down
31 changes: 21 additions & 10 deletions aws/resource_aws_organizations_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,15 @@ func testAccAwsOrganizationsOrganization_AwsServiceAccessPrincipals(t *testing.T
})
}

func testAccAwsOrganizationsOrganization_EnabledPolicyTypes(t *testing.T) {
var organization organizations.Organization
func addTestStepsAwsOrganizationsOrganization_EnabledPolicyTypes(policyTypes *[]string) *[]resource.TestStep {
nikolaifa marked this conversation as resolved.
Show resolved Hide resolved
resourceName := "aws_organizations_organization.test"
var organization organizations.Organization
var testSteps []resource.TestStep

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOrganizationsAccountPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsOrganizationsOrganizationDestroy,
Steps: []resource.TestStep{
for _, policyType := range *policyTypes {
testSteps = append(testSteps, []resource.TestStep{
{
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(organizations.PolicyTypeServiceControlPolicy),
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(policyType),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
Expand All @@ -123,13 +121,26 @@ func testAccAwsOrganizationsOrganization_EnabledPolicyTypes(t *testing.T) {
),
},
{
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(organizations.PolicyTypeServiceControlPolicy),
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(policyType),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
),
},
},
}...)
}
return &testSteps
}

func testAccAwsOrganizationsOrganization_EnabledPolicyTypes(t *testing.T) {
policyTypes := []string{organizations.PolicyTypeServiceControlPolicy, organizations.PolicyTypeTagPolicy}
testSteps := *addTestStepsAwsOrganizationsOrganization_EnabledPolicyTypes(&policyTypes)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t); testAccOrganizationsAccountPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsOrganizationsOrganizationDestroy,
Steps: testSteps,
})
}

Expand Down