0
0
Terraformcloud~10 mins

Splat expressions in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get all instance IDs from the aws_instance resource.

Terraform
output "instance_ids" {
  value = aws_instance.example[1].id
}
Drag options to blanks, or click blank then click option'
A[*]
B.*
C[.]
D[+]
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot (.) instead of [*] for splat expression
Using incorrect brackets like [.] or [+]
2fill in blank
medium

Complete the code to get all private IP addresses from multiple aws_instance resources.

Terraform
output "private_ips" {
  value = aws_instance.web[1].private_ip
}
Drag options to blanks, or click blank then click option'
A.*
B[*]
C[]
D[.]
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot-star (.*) which is invalid in Terraform
Using empty brackets [] without asterisk
3fill in blank
hard

Fix the error in the splat expression to correctly get all subnet IDs.

Terraform
output "subnet_ids" {
  value = aws_subnet.example[1].id
}
Drag options to blanks, or click blank then click option'
A[*]
B.*
C.[]
D[.]
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot-star (.*) which is not valid in Terraform
Using dot with brackets like .[] or [.]
4fill in blank
hard

Fill both blanks to create a list of all security group names from aws_security_group resources.

Terraform
output "sg_names" {
  value = aws_security_group.[1][2].name
}
Drag options to blanks, or click blank then click option'
Aweb
Bdb
C[*]
D.*
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot-star (.*) instead of [*]
Using wrong resource name like db instead of web
5fill in blank
hard

Fill all three blanks to output a list of all tags 'Name' values from aws_instance resources.

Terraform
output "instance_names" {
  value = aws_instance.[1][2].tags[3]
}
Drag options to blanks, or click blank then click option'
Aapp
B[*]
C["Name"]
D.*
Attempts:
3 left
💡 Hint
Common Mistakes
Using dot-star (.*) instead of [*]
Accessing tags.Name instead of tags["Name"]
Using wrong resource name like web instead of app