This function finds all resource instances of a specific type in the state of the current workspace using the tfstate/v2 import.
This function is contained in the tfstate-functions.sentinel module.
find_resources = func(type)
- type: the type of resource to find, given as a string.
None
This function returns a single flat map of resource 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
:
currentEC2Instances = state.find_resources("aws_instance")
currentAzureVMs = state.find_resources("azurerm_virtual_machine")
currentGCEInstances = state.find_resources("google_compute_instance")
currentVMs = state.find_resources("vsphere_virtual_machine")
This function is used by several policies including restrict-current-ec2-instance-type.sentinel (AWS) and restrict-publishers-of-current-vms.sentinel (Azure).