Course outlines for learning terraform.
expected time | requirements |
---|---|
60 minutes | A computer with Terraform installed. |
Goal: Learn how to get data from a provider and use it.
Sometimes you need to “read” a detail in order to provision your code. Some example can be:
You may want to use the found data further in your code.
# Find all images from a specified family and project.
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}
# Make a resource based on the found image.
resource "google_compute_instance" "default" {
# ...
boot_disk {
initialize_params {
image = data.google_compute_image.my_image.self_link
}
}
}
Most providers have two sides to a resource:
resource
- To describe the resources to created.data
- To find resources.Here.
main.tf
to find the images.local_file
) with the images found.