0
0
Terraformcloud~20 mins

Meta-arguments overview in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Meta-Arguments Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of Terraform meta-arguments

Which of the following best describes the purpose of Terraform meta-arguments?

AThey control how Terraform manages resource creation, updates, and dependencies.
BThey define the cloud provider credentials and authentication methods.
CThey specify the exact hardware specifications for virtual machines.
DThey are used to write conditional expressions inside resource blocks.
Attempts:
2 left
💡 Hint

Think about arguments that affect resource lifecycle and dependencies.

Configuration
intermediate
2:00remaining
Effect of count meta-argument on resource instances

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
}
A3 instances
B0 instances
C1 instance
DDepends on the number of availability zones
Attempts:
2 left
💡 Hint

The count meta-argument controls how many copies of the resource are created.

Architecture
advanced
2:00remaining
Using depends_on to control resource creation order

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?

AAdd <code>depends_on = [aws_subnet.subnet1]</code> inside <code>aws_vpc.main</code> resource block.
BUse <code>count = 0</code> in <code>aws_subnet.subnet1</code> until VPC is created.
CNo need to specify; Terraform automatically orders resources alphabetically.
DAdd <code>depends_on = [aws_vpc.main]</code> inside <code>aws_subnet.subnet1</code> resource block.
Attempts:
2 left
💡 Hint

Think about which resource depends on the other.

security
advanced
2:00remaining
Impact of lifecycle meta-argument on resource deletion

What is the effect of setting lifecycle { prevent_destroy = true } in a Terraform resource block?

ATerraform will delete the resource immediately without confirmation.
BTerraform will refuse to delete the resource, preventing accidental destruction.
CTerraform will ignore changes to the resource's attributes during updates.
DTerraform will automatically recreate the resource if deleted outside Terraform.
Attempts:
2 left
💡 Hint

Consider what 'prevent_destroy' implies about resource safety.

service_behavior
expert
2:00remaining
Behavior of for_each meta-argument with map input

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
}
ANo resources will be created due to syntax error
B[0, 1]
C["alpha", "beta"]
D["us-east-1", "us-west-2"]
Attempts:
2 left
💡 Hint

Recall how for_each uses map keys as resource instance keys.