Skip to content

Latest commit

 

History

History
34 lines (23 loc) · 1.65 KB

File metadata and controls

34 lines (23 loc) · 1.65 KB

This function finds all resource instances of a specific type in the state of the current workspace using the tfstate/v2 import.

Sentinel Module

This function is contained in the tfstate-functions.sentinel module.

Declaration

find_resources = func(type)

Arguments

  • type: the type of resource to find, given as a string.

Common Functions Used

None

What It Returns

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.

What It Prints

This function does not print anything.

Examples

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).