0
0
Terraformcloud~10 mins

Why testing infrastructure matters 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 initialize Terraform before applying changes.

Terraform
terraform [1]
Drag options to blanks, or click blank then click option'
Ainit
Bapply
Cplan
Ddestroy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' before initialization causes errors.
Confusing 'plan' with 'init'.
2fill in blank
medium

Complete the code to preview infrastructure changes without applying them.

Terraform
terraform [1]
Drag options to blanks, or click blank then click option'
Avalidate
Bplan
Cdestroy
Dapply
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' when only previewing changes.
Confusing 'validate' with planning.
3fill in blank
hard

Fix the error in the Terraform configuration to ensure resource names are unique.

Terraform
resource "aws_instance" "[1]" {
  ami           = "ami-12345678"
  instance_type = "t2.micro"
}
Drag options to blanks, or click blank then click option'
Aaws_instance
Binstance
Cwebserver
Dresource
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'resource' as the resource name.
Using the provider name as the resource name.
4fill in blank
hard

Fill both blanks to create a variable with a default value and use it in the resource.

Terraform
variable "[1]" {
  type    = string
  default = "t2.micro"
}

resource "aws_instance" "example" {
  ami           = "ami-12345678"
  instance_type = var.[2]
}
Drag options to blanks, or click blank then click option'
Ainstance_type
Bami_id
Dregion
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching variable name and usage.
Using unrelated variable names.
5fill in blank
hard

Fill all three blanks to output the public IP of an AWS instance after deployment.

Terraform
output "[1]" {
  value = aws_instance.[2].[3]
}
Drag options to blanks, or click blank then click option'
Ainstance_ip
Bexample
Cpublic_ip
Dprivate_ip
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'private_ip' instead of 'public_ip'.
Mismatching resource names.