Skip to content

d/aws_servicecatalog_portfolio: add name argument as an alternative to id - #49278

Open
RajeshRajendiran wants to merge 3 commits into
hashicorp:mainfrom
RajeshRajendiran:f-servicecatalog_portfolio_data_source-name
Open

d/aws_servicecatalog_portfolio: add name argument as an alternative to id#49278
RajeshRajendiran wants to merge 3 commits into
hashicorp:mainfrom
RajeshRajendiran:f-servicecatalog_portfolio_data_source-name

Conversation

@RajeshRajendiran

Copy link
Copy Markdown
Contributor

Summary

Closes #49258. The aws_servicecatalog_portfolio data source required id for lookup, even though id is only unique within a single account and name (DisplayName) is what's actually known and referenced in most workflows -- e.g. associating a portfolio with a product or an IAM principal by name. A prior issue requesting this (#20719) was closed without action.

ListPortfolios has no server-side name filter (confirmed against the API model), so the name lookup path paginates through ListPortfolios and filters client-side on DisplayName, following the exact same paginate-and-filter pattern already used in this package for findProductPortfolioAssociations in find.go. It errors if more than one portfolio matches the given name (via the existing tfresource.AssertSingleValueResult helper), since DisplayName isn't guaranteed unique. Once resolved to an id, the rest of the read path (DescribePortfolio) is unchanged.

id changes from Required to Optional+Computed, name from Computed-only to Optional+Computed, with ExactlyOneOf enforcing exactly one is set.

Test plan

  • go build ./internal/service/servicecatalog/...
  • go vet ./internal/service/servicecatalog/...
  • go test ./internal/service/servicecatalog/... (offline unit tests)
  • TestAccServiceCatalogPortfolioDataSource_name (new, added in this PR) -- not run locally, requires AWS credentials with Service Catalog access

…o id

ListPortfolios has no server-side name filter, so name-based lookup
paginates and filters client-side by DisplayName, matching the
existing findProductPortfolioAssociations pattern in this package.
Errors if more than one portfolio matches the given name.
@RajeshRajendiran
RajeshRajendiran requested a review from a team as a code owner August 4, 2026 15:19
@dosubot dosubot Bot added the enhancement Requests to existing resources that expand the functionality or scope. label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Community Guidelines

This comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀

Voting for Prioritization

  • Please vote on this Pull Request by adding a 👍 reaction to the original post to help the community and maintainers prioritize it.
  • Please see our prioritization guide for additional information on how the maintainers handle prioritization.
  • Please do not leave +1 or other comments that do not add relevant new information or questions; they generate extra noise for others following the Pull Request and do not help prioritize the request.

Pull Request Authors

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • 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 needs-triage Waiting for first response or review from a maintainer. documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/servicecatalog Issues and PRs that pertain to the servicecatalog service. size/M Managed by automation to categorize the size of a PR. labels Aug 4, 2026
Clarify that ListPortfolios does not document
ResourceNotFoundException (unlike ListPortfoliosForProduct, which
findProductPortfolioAssociations models); the check is kept only for
structural consistency with that pattern.
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. enhancement Requests to existing resources that expand the functionality or scope. needs-triage Waiting for first response or review from a maintainer. service/servicecatalog Issues and PRs that pertain to the servicecatalog service. size/M 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.

aws_servicecatalog_portfolio search by name, return id

1 participant