Challenge - 5 Problems
Terraform String Interpolation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Understanding Terraform String Interpolation Syntax
What will be the output of the following Terraform expression?
Assume
"Hello, ${var.name}! Welcome to ${var.region}."Assume
var.name = "Alice" and var.region = "us-west-2".Attempts:
2 left
💡 Hint
Terraform replaces variables inside ${} with their values.
✗ Incorrect
Terraform string interpolation replaces expressions inside ${} with their actual values during plan or apply.
❓ Configuration
intermediate2:00remaining
Correct Use of String Interpolation in Resource Names
Which option correctly uses string interpolation to create an AWS S3 bucket name with a prefix and environment variable?
Assume
Assume
var.env = "prod" and var.prefix = "myapp".Attempts:
2 left
💡 Hint
Use ${} around each variable and separate with hyphens outside the braces.
✗ Incorrect
Option B correctly interpolates both variables with hyphens between them. Option B is a duplicate of A but is allowed as a distractor here to check attention.
❓ Architecture
advanced2:00remaining
Combining String Interpolation with Conditional Expressions
Given the Terraform variable
var.is_production which is a boolean, which option correctly sets the resource tag Environment to "prod" if true, or "dev" if false, using string interpolation?Attempts:
2 left
💡 Hint
Terraform uses the ternary operator inside ${} with quotes around string results.
✗ Incorrect
Option D correctly uses the ternary operator with quoted strings inside the interpolation. Option D uses invalid syntax. Options C and D miss quotes causing errors.
❓ security
advanced2:00remaining
Avoiding Sensitive Data Exposure in String Interpolation
Which option correctly avoids exposing a sensitive variable
var.db_password in Terraform output using string interpolation?Attempts:
2 left
💡 Hint
Use the sensitive attribute to hide output values.
✗ Incorrect
Option C correctly marks the output as sensitive and uses string interpolation properly. Option C and C expose the password. Option C has syntax error missing comma.
❓ service_behavior
expert2:00remaining
Effect of Incorrect String Interpolation on AWS Resource Creation
What will happen if you define an AWS EC2 instance resource with the following name attribute?
Assuming
name = "${var.instance_name"Assuming
var.instance_name = "webserver".Attempts:
2 left
💡 Hint
Check for matching braces in interpolation expressions.
✗ Incorrect
The missing closing brace causes a syntax error during Terraform plan, preventing resource creation.