Course outlines for learning terraform.
Sometimes you may need to refer to an attribute that a resource has, without managing the resource.
For example:
In such cases, you can use the data sources.
Here is an example: (shortened to improve readability.)
data "azurerm_dns_zone" "example" {
name = "example.com"
}
resource "azurerm_dns_a_record" "www" {
name = "www"
zone_name = data.azurerm_dns_zone.example.name
ttl = 300
records = ["10.0.180.17"]
}
As you can see from the example above
data
instead of resource
when finding the resource.data.
to the name of the resouce to refer to it.