Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a list of doubled numbers using a for expression.
Terraform
output "doubled" { value = [for num in var.numbers : num [1] 2] }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + instead of * will add 2 instead of doubling.
Using / or - will not double the numbers.
✗ Incorrect
The for expression multiplies each number by 2 using the * operator.
2fill in blank
mediumComplete the code to create a map of instance names to their IDs using a for expression.
Terraform
output "instance_map" { value = {for inst in var.instances : inst.name => inst.[1] }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inst.name as value duplicates the key.
Using inst.type or inst.count are not valid for IDs.
✗ Incorrect
The for expression maps instance names to their IDs using inst.id.
3fill in blank
hardFix the error in the for expression to filter only even numbers.
Terraform
output "even_numbers" { value = [for n in var.numbers : n if n [1] 2 == 0] }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using + or * will not filter even numbers.
Using / returns a quotient, not remainder.
✗ Incorrect
The modulo operator % checks if a number is even by testing remainder 0.
4fill in blank
hardFill both blanks to create a map of server names to their IP addresses, filtering only active servers.
Terraform
output "active_servers" { value = {for s in var.servers : s.[1] => s.[2] if s.active} }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using id or status instead of name or ip.
Not filtering by active status.
✗ Incorrect
The map uses server name as key and IP as value, filtering active servers.
5fill in blank
hardFill all three blanks to create a map of uppercase user names to their emails, filtering users with verified emails.
Terraform
output "verified_user_emails" { value = {for user in var.users : user.[1].[2]() => user.[3] if user.email_verified} }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lower() instead of upper() for names.
Using email_verified as key instead of filtering condition.
✗ Incorrect
The map uses uppercase user names as keys and emails as values, filtering verified emails.