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

d/aws_iam_service_linked_role: new data source #39441

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

alexbacchin
Copy link
Contributor

@alexbacchin alexbacchin commented Sep 23, 2024

New data source:

  • aws_iam_service_linked_role

Migrated data source:

  • aws_iam_roles

Description

This data source returns a service linked role. It also can ensure its existence. As service linked roles can be created either by aws_iam_service_linked_role resource or AWS itself when a service is invoked. It makes difficult to maintain modules that include the aws_iam_service_linked_role resource.
The import is a viable option is some scenarios, but not practical when 2 modules need this to ensure this role is present.

The aws_iam_roles data source was migrated to Terraform Plugin Framework and modified to expose the find roles function.

Relations

Closes #29318
Relates: hashicorp/terraform#33633

References

Output from Acceptance Testing

% make testacc TESTS=TestAccIAMServiceLinkedRoleDataSource PKG=iam
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.7 test ./internal/service/iam/... -v -count 1 -parallel 20 -run='TestAccIAMServiceLinkedRoleDataSource'  -timeout 360m
=== RUN   TestAccIAMServiceLinkedRoleDataSource_basic
=== PAUSE TestAccIAMServiceLinkedRoleDataSource_basic
=== RUN   TestAccIAMServiceLinkedRoleDataSource_customSuffix
=== PAUSE TestAccIAMServiceLinkedRoleDataSource_customSuffix
=== RUN   TestAccIAMServiceLinkedRoleDataSource_createIfMissing
=== PAUSE TestAccIAMServiceLinkedRoleDataSource_createIfMissing
=== CONT  TestAccIAMServiceLinkedRoleDataSource_basic
=== CONT  TestAccIAMServiceLinkedRoleDataSource_createIfMissing
=== CONT  TestAccIAMServiceLinkedRoleDataSource_customSuffix
--- PASS: TestAccIAMServiceLinkedRoleDataSource_createIfMissing (22.75s)
--- PASS: TestAccIAMServiceLinkedRoleDataSource_customSuffix (22.85s)
--- PASS: TestAccIAMServiceLinkedRoleDataSource_basic (23.76s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/iam        23.854s
...
%make testacc TESTS=TestAccIAMRolesDataSource PKG=iam
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.7 test ./internal/service/iam/... -v -count 1 -parallel 20 -run='TestAccIAMRolesDataSource'  -timeout 360m
=== RUN   TestAccIAMRolesDataSource_basic
=== PAUSE TestAccIAMRolesDataSource_basic
=== RUN   TestAccIAMRolesDataSource_nameRegex
=== PAUSE TestAccIAMRolesDataSource_nameRegex
=== RUN   TestAccIAMRolesDataSource_pathPrefix
=== PAUSE TestAccIAMRolesDataSource_pathPrefix
=== RUN   TestAccIAMRolesDataSource_nonExistentPathPrefix
=== PAUSE TestAccIAMRolesDataSource_nonExistentPathPrefix
=== RUN   TestAccIAMRolesDataSource_nameRegexAndPathPrefix
=== PAUSE TestAccIAMRolesDataSource_nameRegexAndPathPrefix
=== CONT  TestAccIAMRolesDataSource_basic
=== CONT  TestAccIAMRolesDataSource_nonExistentPathPrefix
=== CONT  TestAccIAMRolesDataSource_pathPrefix
=== CONT  TestAccIAMRolesDataSource_nameRegexAndPathPrefix
=== CONT  TestAccIAMRolesDataSource_nameRegex
--- PASS: TestAccIAMRolesDataSource_basic (12.26s)
--- PASS: TestAccIAMRolesDataSource_nonExistentPathPrefix (12.28s)
--- PASS: TestAccIAMRolesDataSource_pathPrefix (16.99s)
--- PASS: TestAccIAMRolesDataSource_nameRegexAndPathPrefix (16.99s)
--- PASS: TestAccIAMRolesDataSource_nameRegex (17.13s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/iam        17.228s
...

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 documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/iam Issues and PRs that pertain to the iam service. sweeper Pertains to changes to or issues with the sweeper. generators Relates to code generators. needs-triage Waiting for first response or review from a maintainer. labels Sep 23, 2024
@alexbacchin alexbacchin marked this pull request as ready for review September 23, 2024 13:16
@alexbacchin alexbacchin requested a review from a team as a code owner September 23, 2024 13:16
@breathingdust breathingdust added new-data-source Introduces a new data source. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Introduces or discusses updates to documentation. generators Relates to code generators. new-data-source Introduces a new data source. service/iam Issues and PRs that pertain to the iam service. sweeper Pertains to changes to or issues with the sweeper. 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]: aws_iam_service_linked_role adopt existing resource
2 participants