Challenge - 5 Problems
Terraform Block Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Configuration
intermediate2:00remaining
Identify the output of this Terraform resource block
Given the following Terraform resource block, what will be the value of the
instance_type attribute after deployment?Terraform
resource "aws_instance" "example" { ami = "ami-12345678" instance_type = "t2.micro" tags = { Name = "ExampleInstance" } }
Attempts:
2 left
💡 Hint
Look at the attribute assigned to
instance_type inside the resource block.✗ Incorrect
The
instance_type attribute is explicitly set to "t2.micro" in the resource block, so after deployment, its value will be "t2.micro".❓ Architecture
intermediate2:00remaining
Determine the number of blocks in this Terraform configuration
How many top-level blocks are defined in the following Terraform configuration snippet?
Terraform
provider "aws" { region = "us-west-2" } resource "aws_s3_bucket" "bucket" { bucket = "my-bucket" acl = "private" } variable "bucket_name" { type = string }
Attempts:
2 left
💡 Hint
Count each block that starts at the left margin with a block type keyword.
✗ Incorrect
There are three top-level blocks:
provider, resource, and variable.❓ security
advanced2:00remaining
Identify the security risk in this Terraform block structure
Which option correctly identifies the security risk in the following Terraform block?
Terraform
resource "aws_security_group" "example" { name = "example-sg" description = "Allow SSH" ingress { from_port = 22 to_port = 22 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } }
Attempts:
2 left
💡 Hint
Consider what allowing SSH from everywhere means for security.
✗ Incorrect
Allowing SSH (port 22) from any IP address (0.0.0.0/0) exposes the instance to the entire internet, increasing risk of unauthorized access.
✅ Best Practice
advanced2:00remaining
Choose the correct block structure to define multiple tags in Terraform
Which option correctly defines multiple tags inside a resource block in Terraform?
Attempts:
2 left
💡 Hint
Terraform uses maps for tags, not lists or tuples.
✗ Incorrect
Terraform expects tags as a map with key-value pairs using = without quotes around keys. Option A uses correct syntax.
❓ service_behavior
expert2:00remaining
Predict the behavior of nested blocks in this Terraform configuration
What will be the effect of the nested
lifecycle block inside this resource block?Terraform
resource "aws_s3_bucket" "example" { bucket = "my-example-bucket" lifecycle { prevent_destroy = true } }
Attempts:
2 left
💡 Hint
Consider what the
prevent_destroy setting does in Terraform lifecycle blocks.✗ Incorrect
The lifecycle block with
prevent_destroy = true tells Terraform to block any destroy action on the resource unless the block is removed or changed.