Challenge - 5 Problems
Terraform Code Review Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Configuration
intermediate2:00remaining
Identify the output of this Terraform resource configuration
Given the following Terraform configuration for an AWS S3 bucket, what will be the value of the bucket's versioning status after applying?
Terraform
resource "aws_s3_bucket" "example" { bucket = "my-example-bucket" versioning { enabled = true } } output "versioning_status" { value = aws_s3_bucket.example.versioning[0].status }
Attempts:
2 left
💡 Hint
Check the versioning block and the output value referencing the status attribute.
✗ Incorrect
The versioning block with enabled = true sets the bucket versioning status to "Enabled". The output references this status correctly.
❓ security
intermediate2:00remaining
Detect the security risk in this Terraform IAM policy
Review the following Terraform IAM policy attached to an AWS IAM role. Which option correctly identifies the security risk?
Terraform
resource "aws_iam_role_policy" "example_policy" { name = "example_policy" role = aws_iam_role.example_role.id policy = jsonencode({ Version = "2012-10-17", Statement = [ { Effect = "Allow", Action = "*", Resource = "*" } ] }) }
Attempts:
2 left
💡 Hint
Look at the Action and Resource fields in the policy statement.
✗ Incorrect
The policy uses "Action": "*" and "Resource": "*", granting full permissions, which is a security risk.
❓ Architecture
advanced2:00remaining
Determine the number of subnets created by this Terraform module
This Terraform module creates subnets in multiple availability zones. Given the following snippet, how many subnets will be created?
Terraform
variable "availability_zones" { default = ["us-east-1a", "us-east-1b", "us-east-1c"] } resource "aws_subnet" "example" { count = length(var.availability_zones) * 2 vpc_id = aws_vpc.example.id cidr_block = cidrsubnet(aws_vpc.example.cidr_block, 8, count.index) availability_zone = var.availability_zones[count.index % length(var.availability_zones)] }
Attempts:
2 left
💡 Hint
Look at the count expression and how it relates to availability zones.
✗ Incorrect
The count is length of availability zones (3) times 2, so 6 subnets are created.
❓ service_behavior
advanced2:00remaining
Predict the behavior of this Terraform apply with lifecycle ignore_changes
Given this Terraform resource with lifecycle ignore_changes on tags, what happens if tags are changed manually outside Terraform and then terraform apply is run?
Terraform
resource "aws_instance" "example" { ami = "ami-12345678" instance_type = "t2.micro" tags = { Environment = "Production" } lifecycle { ignore_changes = ["tags"] } }
Attempts:
2 left
💡 Hint
Consider what ignore_changes does in lifecycle blocks.
✗ Incorrect
ignore_changes on tags means Terraform ignores any manual tag changes and does not revert them.
✅ Best Practice
expert2:00remaining
Identify the best practice violation in this Terraform state management setup
A team uses local state files for their Terraform project shared by multiple engineers. What is the main risk of this approach?
Attempts:
2 left
💡 Hint
Think about how Terraform state files are shared and locked.
✗ Incorrect
Local state files do not support locking, so multiple users can overwrite state causing conflicts.