0
0
Terraformcloud~10 mins

Why resources are Terraform's core - Test Your Understanding

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

Complete the code to define a resource block in Terraform.

Terraform
resource "aws_instance" "example" {
  ami           = "ami-123456"
  instance_type = [1]
}
Drag options to blanks, or click blank then click option'
A"t2.micro"
C"m5.large"
D"c5.xlarge"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect instance type strings like 't2.micro' misspelled.
Confusing AMI IDs with instance types.
2fill in blank
medium

Complete the code to reference the resource's attribute.

Terraform
output "instance_ip" {
  value = aws_instance.example.[1]
}
Drag options to blanks, or click blank then click option'
Aprivate_dns
Bid
Cpublic_ip
Davailability_zone
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' which is the instance ID, not the IP address.
Using 'private_dns' which is not an IP address.
3fill in blank
hard

Fix the error in the resource block by completing the missing argument.

Terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket = [1]
  acl    = "private"
}
Drag options to blanks, or click blank then click option'
A"my_bucket!"
B"my-bucket-123"
C"my bucket"
D"123_my_bucket"
Attempts:
3 left
💡 Hint
Common Mistakes
Using spaces or underscores in bucket names.
Starting bucket names with numbers or special characters.
4fill in blank
hard

Fill both blanks to create a resource with tags.

Terraform
resource "aws_instance" "web" {
  ami           = "ami-abc123"
  instance_type = [1]
  tags = {
    Name = [2]
  }
}
Drag options to blanks, or click blank then click option'
A"t3.micro"
B"WebServer"
C"t2.micro"
D"MyInstance"
Attempts:
3 left
💡 Hint
Common Mistakes
Quoting instance types or not quoting tag values.
Using invalid instance types.
5fill in blank
hard

Fill all three blanks to define a resource with lifecycle rules.

Terraform
resource "aws_s3_bucket" "archive" {
  bucket = [1]
  acl    = "private"
  lifecycle {
    prevent_destroy = [2]
    ignore_changes  = [[3]]
  }
}
Drag options to blanks, or click blank then click option'
A"archive-bucket-001"
Btrue
C"tags"
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting string values.
Using false instead of true for prevent_destroy when protection is needed.