Open ericksoen opened 4 years ago
Thanks for this issue, @ericksoen. Typically, our acceptance tests are written to be standalone. As you've found, this can cause problems with some services. We've been talking on our team about some approaches we can take to deal with these more challenging services. Go 1.14 added a new Cleanup()
function which could help with this.
Community Note
Description
I've noticed that when I run the AWS Organizations Acceptance tests, I frequently encounter an error from the configured
testAccOrganizationsAccountPreCheck
that outputs the error "skipping tests; this AWS account must not be an existing member of an AWS Organization". The AWS Organizations API doesn't make it easy to leave an organization, e.g., the master account can't leave an organization and a member account receives the error "ConstraintViolationException when calling the LeaveOrganization operation. This operation requires a wait period" (without much supporting documentation from AWS regarding the duration of the wait period).To make acceptance tests easier to run repeatedly, I was curious about the changing the behavior to remove the
resource "aws_organizations_organization" "test" {}
from certain acceptance tests and adding a PreTestCheck that validates that the account where acceptance tests are being run includes an AWS Organization. Alternatively (or in addition), where an explicitly AWS Organization resource is required, using thedata aws_organizations_organization
data source to get a provider reference.New or Affected Resource(s)
*_test.go
files. Potentially impacted files include:provider_test.go
resource_aws_organizations_policy_test.go
resource_aws_organization_policy_attachment_test.go
resource_aws_organization_account_test.go
Potential Terraform Configuration
References