You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The specific problem I'm trying to solve is to automatically set up dynamic credentials between Azure and Terraform Cloud, this requires me to build a subject identifier that contains both the Project and Workspace names. However most of the data sources only support searching by Name. For example when fetching the Workspace you only get the Project ID returned, likewise when getting the Project you only get the Workspace IDs returned. It isn't possible to then use those IDs to find the other related resources.
Attempted Solutions
As mentioned in issue #778 there are a few workarounds via things like terracurl to fetch information from the API directly.
Proposal
While my use case only relates to a couple of data sources, it feels like it would be better for consistency to update others at the same time too. As such I'd like to update all of the relevant data sources to make it so they can be queried by either the ID or the Name. This would involve adding appropriate logic to those data sources so they can determine whether the name or ID has been provided and then call the relevant API to fetch the information. As far as I can tell all of these Types in go-tfe have a Read() function that allows you to get by ID.
Fetching by ID would also have the benefit of being slightly more efficient as many of the existing data sources seem to first fetch a list, then iterate to find the one you want in that list.
The specific data sources I'd like to update are:
tfe_agent_pool
tfe_policy_set
tfe_project
tfe_ssh_key
tfe_team
tfe_variable_set
tfe_workspace
(let me know if I've missed any that should be included)
An example of the updated data source would probably look something like this:
Use-cases
Also relates to #778
The specific problem I'm trying to solve is to automatically set up dynamic credentials between Azure and Terraform Cloud, this requires me to build a subject identifier that contains both the Project and Workspace names. However most of the data sources only support searching by Name. For example when fetching the Workspace you only get the Project ID returned, likewise when getting the Project you only get the Workspace IDs returned. It isn't possible to then use those IDs to find the other related resources.
Attempted Solutions
As mentioned in issue #778 there are a few workarounds via things like terracurl to fetch information from the API directly.
Proposal
While my use case only relates to a couple of data sources, it feels like it would be better for consistency to update others at the same time too. As such I'd like to update all of the relevant data sources to make it so they can be queried by either the ID or the Name. This would involve adding appropriate logic to those data sources so they can determine whether the name or ID has been provided and then call the relevant API to fetch the information. As far as I can tell all of these Types in go-tfe have a
Read()
function that allows you to get by ID.Fetching by ID would also have the benefit of being slightly more efficient as many of the existing data sources seem to first fetch a list, then iterate to find the one you want in that list.
The specific data sources I'd like to update are:
(let me know if I've missed any that should be included)
An example of the updated data source would probably look something like this:
I figured since this would change quite a few data sources I'd better check first. If this is a desirable change I'd be happy to submit a PR for it.
The text was updated successfully, but these errors were encountered: