Created
March 12, 2019 15:06
-
-
Save mijdavis2/0487a21602885cc3113e3249b5bad32a to your computer and use it in GitHub Desktop.
How to get available AZs in terraform from data and subnet list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_availability_zones" "available" {} | |
# Assuming we vars for list of private_subnet_ids and or public_subnet_ids | |
# we take a slice of available AZs. | |
# | |
# Add or remove private/public vars when necessary. | |
locals { | |
available_azs = "${ | |
slice( | |
data.aws_availability_zones.available.names, | |
0, | |
max(length(var.private_subnet_ids), length(var.public_subnet_ids))) | |
}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment