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

r/aws_organizations_organization: Add support for AISERVICES_OPT_OUT_POLICY #14650

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -144,6 +144,7 @@ func resourceAwsOrganizationsOrganization() *schema.Resource {
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validation.StringInSlice([]string{
organizations.PolicyTypeAiservicesOptOutPolicy,
organizations.PolicyTypeBackupPolicy,
organizations.PolicyTypeServiceControlPolicy,
organizations.PolicyTypeTagPolicy,
Expand Down
12 changes: 12 additions & 0 deletions aws/resource_aws_organizations_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func testAccAwsOrganizationsOrganization_EnabledPolicyTypes(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.0", organizations.PolicyTypeServiceControlPolicy),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When testing TypeSet attributes, we need to use special testing functions due to the special indexing (the .0 working in this case will no longer be supported in the future):

// In the imports
"github.com/terraform-providers/terraform-provider-aws/aws/internal/tfawsresource"

// In the testing, for example this line
tfawsresource.TestCheckTypeSetElemAttr(resourceName, "enabled_policy_types.*", organizations.PolicyTypeServiceControlPolicy),

The same will need to be applied to the other testing below, however I think we will just get this in as-is right now since its still passing. 👍 These testing functions will be moved into the Terraform Plugin SDK in the coming weeks and the SDK should make these issues more noticeable in the future when that implementation is completed.

),
},
{
Expand All @@ -123,25 +124,36 @@ func testAccAwsOrganizationsOrganization_EnabledPolicyTypes(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "0"),
),
},
{
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(organizations.PolicyTypeAiservicesOptOutPolicy),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.0", organizations.PolicyTypeAiservicesOptOutPolicy),
),
},
{
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(organizations.PolicyTypeServiceControlPolicy),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.0", organizations.PolicyTypeServiceControlPolicy),
),
},
{
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(organizations.PolicyTypeBackupPolicy),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.0", organizations.PolicyTypeBackupPolicy),
),
},
{
Config: testAccAwsOrganizationsOrganizationConfigEnabledPolicyTypes1(organizations.PolicyTypeTagPolicy),
Check: resource.ComposeTestCheckFunc(
testAccCheckAwsOrganizationsOrganizationExists(resourceName, &organization),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.#", "1"),
resource.TestCheckResourceAttr(resourceName, "enabled_policy_types.0", organizations.PolicyTypeTagPolicy),
),
},
{
Expand Down