Skip to content

Instantly share code, notes, and snippets.

@KyMidd

KyMidd/asdf.tf Secret

Created June 7, 2024 16:35
Show Gist options
  • Save KyMidd/a78fd1178ce939e72bf04ab25b1b4c2a to your computer and use it in GitHub Desktop.
Save KyMidd/a78fd1178ce939e72bf04ab25b1b4c2a to your computer and use it in GitHub Desktop.
# Filter list for RasGw RG name
locals {
rg = [for rg in jsondecode(data.azapi_resource_list.subscription_rgs.output).value[*] : rg.name if can(regex("Terraform", rg.name))]
}
# Find all VMs in GW Subnet using AZAPI
data "azapi_resource_list" "server" {
count = length(local.rg) == 0 ? 0 : 1
type = "Microsoft.Compute/virtualMachines@2024-03-01"
parent_id = "/subscriptions/${data.azurerm_subscription.current.subscription_id}/resourceGroups/${local.rg}"
response_export_values = ["*"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment