Data Source: azurermResources
Use this data source to access information about existing resources.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as azurerm from "./.gen/providers/azurerm";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: azurerm.
For a more precise conversion please use the --provider flag in convert.*/
new azurerm.dataAzurermResources.DataAzurermResources(this, "example", {
resource_group_name: "example-resources",
});
const dataAzurermResourcesSpokes =
new azurerm.dataAzurermResources.DataAzurermResources(this, "spokes", {
required_tags: [
{
environment: "production",
role: "spokeNetwork",
},
],
type: "Microsoft.Network/virtualNetworks",
});
const azurermVirtualNetworkPeeringSpokePeers =
new azurerm.virtualNetworkPeering.VirtualNetworkPeering(this, "spoke_peers", {
name: `hub2\${${dataAzurermResourcesSpokes.resources.fqn}[count.index].name}`,
remote_virtual_network_id: `\${${dataAzurermResourcesSpokes.resources.fqn}[count.index].id}`,
resource_group_name: "${azurerm_resource_group.hub.name}",
virtual_network_name: "${azurerm_virtual_network.hub.name}",
});
/*In most cases loops should be handled in the programming language context and
not inside of the Terraform context. If you are looping over something external, e.g. a variable or a file input
you should consider using a for loop. If you are looping over something only known to Terraform, e.g. a result of a data source
you need to keep this like it is.*/
azurermVirtualNetworkPeeringSpokePeers.addOverride(
"count",
`\${length(${dataAzurermResourcesSpokes.resources})}`
);
Argument Reference
\~> Note: At least one of name
, resourceGroupName
or type
must be specified.
-
name
- (Optional) The name of the Resource. -
resourceGroupName
- (Optional) The name of the Resource group where the Resources are located. -
type
- (Optional) The Resource Type of the Resources you want to list (e.g.microsoftNetwork/virtualNetworks
). A full list of available Resource Types can be found here. -
requiredTags
- (Optional) A mapping of tags which the resource has to have in order to be included in the result.
Attributes Reference
resources
- One or moreresource
blocks as defined below.
The resource
block exports the following:
-
name
- The name of this Resource. -
id
- The ID of this Resource. -
type
- The type of this Resource. (e.g.microsoftNetwork/virtualNetworks
). -
location
- The Azure Region in which this Resource exists. -
tags
- A map of tags assigned to this Resource.
Timeouts
The timeouts
block allows you to specify timeouts for certain actions:
read
- (Defaults to 5 minutes) Used when retrieving the Resources.