0
0
Terraformcloud~10 mins

Availability zones data source 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 fetch availability zones in the current region.

Terraform
data "aws_availability_zones" "available" {
  state = "[1]"
}
Drag options to blanks, or click blank then click option'
Aenabled
Bactive
Cavailable
Dpresent
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect state values like 'active' or 'enabled' which are invalid.
2fill in blank
medium

Complete the code to output the list of availability zone names.

Terraform
output "az_names" {
  value = data.aws_availability_zones.available.[1]
}
Drag options to blanks, or click blank then click option'
Anames
Bids
Czone_ids
Dzones
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'zones' or 'ids' which are not valid attributes for names.
3fill in blank
hard

Fix the error in the data source block to correctly filter zones by state.

Terraform
data "aws_availability_zones" "filtered" {
  state = "[1]"
}
Drag options to blanks, or click blank then click option'
Aenabled
Bavailable
Cpresent
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid state values like 'enabled' or 'active' causes errors.
4fill in blank
hard

Fill both blanks to create a data source that fetches only available zones and outputs their count.

Terraform
data "aws_availability_zones" "example" {
  state = "[1]"
}

output "az_count" {
  value = length(data.aws_availability_zones.example.[2])
}
Drag options to blanks, or click blank then click option'
Aavailable
Bnames
Czones
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'active' as state or 'zones' as attribute causes errors.
5fill in blank
hard

Fill all three blanks to create a data source fetching available zones, output their names, and output their count.

Terraform
data "aws_availability_zones" "all" {
  state = "[1]"
}

output "all_az_names" {
  value = data.aws_availability_zones.all.[2]
}

output "all_az_count" {
  value = length(data.aws_availability_zones.all.[3])
}
Drag options to blanks, or click blank then click option'
Aavailable
Bnames
Dactive
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'active' as state or wrong attributes for outputs.