0
0
Terraformcloud~10 mins

Why meta-arguments control resource behavior in Terraform - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the resource count.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
  count         = [1]
}
Drag options to blanks, or click blank then click option'
Acount
B1
Ctrue
Dfor_each
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' as a value instead of a number.
Confusing 'count' with 'for_each'.
2fill in blank
medium

Complete the code to use the 'depends_on' meta-argument correctly.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
  depends_on    = [[1]]
}
Drag options to blanks, or click blank then click option'
A"sg"
Baws_security_group.sg
C"aws_security_group.sg"
Dsg
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the resource address.
Using variable names instead of resource addresses.
3fill in blank
hard

Fix the error in the 'lifecycle' meta-argument to prevent resource destruction.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = "t2.micro"
  lifecycle     = {
    [1] = true
  }
}
Drag options to blanks, or click blank then click option'
Aprevent_destroy
Bignore_changes
Ccreate_before_destroy
Dreplace_triggered_by
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create_before_destroy' which controls replacement order, not destruction prevention.
Confusing 'ignore_changes' with destruction protection.
4fill in blank
hard

Fill both blanks to create multiple resources with unique names using 'for_each'.

Terraform
resource "aws_s3_bucket" "example" {
  for_each = [1]
  bucket   = "my-bucket-$[2]"
  acl      = "private"
}
Drag options to blanks, or click blank then click option'
Atoset(["one", "two", "three"])
Beach.key
Ceach.value
D["one", "two", "three"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using a list directly without converting to set for for_each.
Using each.value instead of each.key for naming.
5fill in blank
hard

Fill all three blanks to ignore changes to the 'tags' attribute and create the resource with a count.

Terraform
resource "aws_instance" "example" {
  count     = [1]
  ami       = "ami-123456"
  instance_type = "t2.micro"
  lifecycle = {
    ignore_changes = [[2]]
  }
  tags = {
    Name = "example-instance"
  }
  depends_on = [[3]]
}
Drag options to blanks, or click blank then click option'
A2
B"tags"
C"aws_security_group.sg"
D"instance_type"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number as a string for count.
Not quoting the attribute name in ignore_changes.
Using variable names instead of resource addresses in depends_on.