Which of the following best describes the purpose of Terraform meta-arguments?
Think about arguments that affect resource lifecycle and dependencies.
Terraform meta-arguments like depends_on, count, and lifecycle control resource management behavior, not credentials or hardware specs.
Given the following Terraform resource snippet, how many instances of aws_instance will be created?
resource "aws_instance" "example" {
ami = "ami-123456"
instance_type = "t2.micro"
count = 3
}The count meta-argument controls how many copies of the resource are created.
Setting count = 3 creates exactly 3 instances of the resource.
Consider two resources: aws_vpc.main and aws_subnet.subnet1. You want to ensure the subnet is created only after the VPC is fully created. Which meta-argument usage achieves this?
Think about which resource depends on the other.
Using depends_on in the subnet resource pointing to the VPC ensures the subnet waits for the VPC creation.
What is the effect of setting lifecycle { prevent_destroy = true } in a Terraform resource block?
Consider what 'prevent_destroy' implies about resource safety.
Setting prevent_destroy = true stops Terraform from deleting the resource, protecting it from accidental removal.
Given this Terraform resource snippet, what will be the keys of the created resources?
resource "aws_s3_bucket" "buckets" {
for_each = {
alpha = "us-east-1"
beta = "us-west-2"
}
bucket = "my-bucket-${each.key}"
region = each.value
}Recall how for_each uses map keys as resource instance keys.
When using a map with for_each, Terraform creates one resource per key, using the keys as instance identifiers.