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

F organizations policies #31546

Merged
merged 14 commits into from
Jun 15, 2023
Merged

Conversation

danielw-aws
Copy link
Contributor

@danielw-aws danielw-aws commented May 23, 2023

Description

Added a data source, tests, and webdocs for a wrapper on Organizations ListPolicies API

Relations

Closes #31545

References

https://docs.aws.amazon.com/organizations/latest/APIReference/API_ListPolicies.html

Output from Acceptance Testing

make testacc  TESTS=TestAccOrganizationsPoliciesDataSource_ PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20 -run='TestAccOrganizationsPoliciesDataSource_'  -timeout 180m
=== RUN   TestAccOrganizationsPoliciesDataSource_basic
--- PASS: TestAccOrganizationsPoliciesDataSource_basic (22.79s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/organizations      25.945s

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/organizations Issues and PRs that pertain to the organizations service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. partner Contribution from a partner. needs-triage Waiting for first response or review from a maintainer. labels May 23, 2023
@github-actions github-actions bot added the generators Relates to code generators. label May 23, 2023
@justinretzolk justinretzolk added new-data-source Introduces a new data source. and removed needs-triage Waiting for first response or review from a maintainer. labels May 24, 2023
danielw-aws and others added 6 commits May 25, 2023 13:13
Acceptance test output:

% make testacc TESTARGS='-run=TestAccOrganizations_serial/Policy$$' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20  -run=TestAccOrganizations_serial/Policy$ -timeout 180m
=== RUN   TestAccOrganizations_serial
=== PAUSE TestAccOrganizations_serial
=== CONT  TestAccOrganizations_serial
=== RUN   TestAccOrganizations_serial/Policy
=== RUN   TestAccOrganizations_serial/Policy/disappears
=== RUN   TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT
=== RUN   TestAccOrganizations_serial/Policy/Type_Backup
=== RUN   TestAccOrganizations_serial/Policy/Type_Tag
=== RUN   TestAccOrganizations_serial/Policy/basic
=== RUN   TestAccOrganizations_serial/Policy/concurrent
=== RUN   TestAccOrganizations_serial/Policy/Description
=== RUN   TestAccOrganizations_serial/Policy/SkipDestroy
=== RUN   TestAccOrganizations_serial/Policy/Tags
=== RUN   TestAccOrganizations_serial/Policy/Type_SCP
=== RUN   TestAccOrganizations_serial/Policy/ImportAwsManagedPolicy
--- PASS: TestAccOrganizations_serial (348.14s)
    --- PASS: TestAccOrganizations_serial/Policy (348.14s)
        --- PASS: TestAccOrganizations_serial/Policy/disappears (22.16s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT (23.33s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_Backup (24.94s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_Tag (26.35s)
        --- PASS: TestAccOrganizations_serial/Policy/basic (39.41s)
        --- PASS: TestAccOrganizations_serial/Policy/concurrent (37.07s)
        --- PASS: TestAccOrganizations_serial/Policy/Description (39.95s)
        --- PASS: TestAccOrganizations_serial/Policy/SkipDestroy (20.15s)
        --- PASS: TestAccOrganizations_serial/Policy/Tags (54.49s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_SCP (36.65s)
        --- PASS: TestAccOrganizations_serial/Policy/ImportAwsManagedPolicy (23.64s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	355.058s
@ewbankkit ewbankkit self-assigned this Jun 15, 2023
Acceptance test output:

% make testacc TESTARGS='-run=TestAccOrganizations_serial/PolicyDataSource$$' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20  -run=TestAccOrganizations_serial/PolicyDataSource$ -timeout 180m
=== RUN   TestAccOrganizations_serial
=== PAUSE TestAccOrganizations_serial
=== CONT  TestAccOrganizations_serial
=== RUN   TestAccOrganizations_serial/PolicyDataSource
=== RUN   TestAccOrganizations_serial/PolicyDataSource/UnattachedPolicy
--- PASS: TestAccOrganizations_serial (30.86s)
    --- PASS: TestAccOrganizations_serial/PolicyDataSource (30.86s)
        --- PASS: TestAccOrganizations_serial/PolicyDataSource/UnattachedPolicy (30.86s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	39.816s
Acceptance test output:

% make testacc TESTARGS='-run=TestAccOrganizationsPoliciesDataSource_' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20  -run=TestAccOrganizationsPoliciesDataSource_ -timeout 180m
=== RUN   TestAccOrganizationsPoliciesDataSource_basic
--- PASS: TestAccOrganizationsPoliciesDataSource_basic (18.56s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	24.302s
@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Jun 15, 2023
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

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

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccOrganizationsPoliciesDataSource_' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20  -run=TestAccOrganizationsPoliciesDataSource_ -timeout 180m
=== RUN   TestAccOrganizationsPoliciesDataSource_basic
--- PASS: TestAccOrganizationsPoliciesDataSource_basic (18.56s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	24.302s
% make testacc TESTARGS='-run=TestAccOrganizations_serial/PolicyDataSource$$' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20  -run=TestAccOrganizations_serial/PolicyDataSource$ -timeout 180m
=== RUN   TestAccOrganizations_serial
=== PAUSE TestAccOrganizations_serial
=== CONT  TestAccOrganizations_serial
=== RUN   TestAccOrganizations_serial/PolicyDataSource
=== RUN   TestAccOrganizations_serial/PolicyDataSource/UnattachedPolicy
--- PASS: TestAccOrganizations_serial (30.86s)
    --- PASS: TestAccOrganizations_serial/PolicyDataSource (30.86s)
        --- PASS: TestAccOrganizations_serial/PolicyDataSource/UnattachedPolicy (30.86s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	39.816s
% make testacc TESTARGS='-run=TestAccOrganizations_serial/Policy$$' PKG=organizations
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/organizations/... -v -count 1 -parallel 20  -run=TestAccOrganizations_serial/Policy$ -timeout 180m
=== RUN   TestAccOrganizations_serial
=== PAUSE TestAccOrganizations_serial
=== CONT  TestAccOrganizations_serial
=== RUN   TestAccOrganizations_serial/Policy
=== RUN   TestAccOrganizations_serial/Policy/disappears
=== RUN   TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT
=== RUN   TestAccOrganizations_serial/Policy/Type_Backup
=== RUN   TestAccOrganizations_serial/Policy/Type_Tag
=== RUN   TestAccOrganizations_serial/Policy/basic
=== RUN   TestAccOrganizations_serial/Policy/concurrent
=== RUN   TestAccOrganizations_serial/Policy/Description
=== RUN   TestAccOrganizations_serial/Policy/SkipDestroy
=== RUN   TestAccOrganizations_serial/Policy/Tags
=== RUN   TestAccOrganizations_serial/Policy/Type_SCP
=== RUN   TestAccOrganizations_serial/Policy/ImportAwsManagedPolicy
--- PASS: TestAccOrganizations_serial (348.14s)
    --- PASS: TestAccOrganizations_serial/Policy (348.14s)
        --- PASS: TestAccOrganizations_serial/Policy/disappears (22.16s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_AI_OPT_OUT (23.33s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_Backup (24.94s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_Tag (26.35s)
        --- PASS: TestAccOrganizations_serial/Policy/basic (39.41s)
        --- PASS: TestAccOrganizations_serial/Policy/concurrent (37.07s)
        --- PASS: TestAccOrganizations_serial/Policy/Description (39.95s)
        --- PASS: TestAccOrganizations_serial/Policy/SkipDestroy (20.15s)
        --- PASS: TestAccOrganizations_serial/Policy/Tags (54.49s)
        --- PASS: TestAccOrganizations_serial/Policy/Type_SCP (36.65s)
        --- PASS: TestAccOrganizations_serial/Policy/ImportAwsManagedPolicy (23.64s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/organizations	355.058s

@ewbankkit
Copy link
Contributor

@danielw-aws Thanks for the contribution 🎉 👏.
I simplified the returned attributes to just ids (list of policy IDs) -- this is our preferred pattern (e.g. aws_subnets):

data "aws_organizations_policies" "example" {
  filter = "SERVICE_CONTROL_POLICY"
}

data "aws_organizations_policy" "example" {
  for_each  = toset(data.aws_organizations_policies.example.ids)
  policy_id = each.value
}

@ewbankkit ewbankkit merged commit c406c8c into hashicorp:main Jun 15, 2023
@github-actions github-actions bot added this to the v5.4.0 milestone Jun 15, 2023
@danielw-aws danielw-aws deleted the f-organizations-policies branch June 15, 2023 19:24
@github-actions
Copy link

This functionality has been released in v5.4.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-data-source Introduces a new data source. partner Contribution from a partner. service/organizations Issues and PRs that pertain to the organizations service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement]: Datasource for Organizations Policies
3 participants