This function finds all data source instances for a specific provider in the state of the current workspace using the tfstate/v2 import.
If you are using Terraform 0.12, use the short form of the provider name such as "null". If you are using Terraform 0.13, you can use the short form or the fully-qualified provider source such as "registry.terraform.io/hashicorp/null", but only use the latter if you are only want to find resources from a specific registry. If you use the short form, the function will reduce rc.provider_name
for each resource to the short form, but if you use the long form, it will not.
This function is contained in the tfstate-functions.sentinel module.
find_datasources_by_provider = func(provider)
- provider: the provider, given as a string.
None
This function returns a single flat map of data source instances indexed by the complete addresses of the instances. The map is actually a filtered sub-collection of the tfstate.resources
collection.
This function does not print anything.
Here are some examples of calling this function, assuming that the tfstate-functions.sentinel file that contains it has been imported with the alias state
:
currentAWSDataSources = state.find_datasources_by_provider("aws")
currentAWSDataSources = state.find_datasources_by_provider("registry.terraform.io/hashicorp/aws")
currentAzureDataSources = state.find_datasources_by_provider("azurerm")
currentGCPDataSources = state.find_datasources_by_provider("google")
currentVMwareDataSources = state.find_datasources_by_provider("vsphere")