0
0
Terraformcloud~20 mins

Resource types and names in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Resource Naming Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Identify the correct resource type in Terraform

Which of the following is the correct resource type for creating an AWS S3 bucket in Terraform?

Abucket_aws_s3
Baws_bucket_s3
Cs3_aws_bucket
Daws_s3_bucket
Attempts:
2 left
💡 Hint

Resource types in Terraform usually start with the provider name, followed by the resource name.

Configuration
intermediate
1:30remaining
Determine the valid resource name in Terraform

Which of the following is a valid resource name in Terraform?

Amy resource
B1myresource
Cmy-resource_1
DmyResource!
Attempts:
2 left
💡 Hint

Resource names must start with a letter or underscore and can contain letters, digits, underscores, and dashes.

Architecture
advanced
2:00remaining
Predict the resource count after applying Terraform configuration

Given the following Terraform configuration snippet, how many AWS EC2 instances will be created?

resource "aws_instance" "web" {
  count = 3
  ami           = "ami-12345678"
  instance_type = "t2.micro"
}

resource "aws_instance" "db" {
  count = 2
  ami           = "ami-87654321"
  instance_type = "t2.micro"
}
A5
B3
C1
D2
Attempts:
2 left
💡 Hint

Count defines how many instances of a resource are created.

security
advanced
1:30remaining
Identify the security risk in resource naming

Which resource naming practice can lead to a security risk in Terraform configurations?

AUsing short, generic resource names
BUsing descriptive names that reveal sensitive environment details
CUsing only lowercase letters and numbers in names
DUsing underscores instead of dashes in resource names
Attempts:
2 left
💡 Hint

Think about what information might be exposed unintentionally.

service_behavior
expert
2:30remaining
Analyze the effect of resource renaming in Terraform state

What happens if you rename a resource block's name in Terraform configuration without using state commands?

Original:
resource "aws_s3_bucket" "mybucket" {
  bucket = "example-bucket"
}

Renamed:
resource "aws_s3_bucket" "mybucket_renamed" {
  bucket = "example-bucket"
}
ATerraform will try to create a new bucket and delete the old one
BTerraform will update the existing bucket in place
CTerraform will ignore the change and do nothing
DTerraform will merge both resources into one
Attempts:
2 left
💡 Hint

Think about how Terraform tracks resources in its state file.