brikis98 / terraform-up-and-running-code

Code samples for the book "Terraform: Up & Running" by Yevgeniy Brikman
http://www.terraformupandrunning.com/
MIT License
2.92k stars 1.93k forks source link

Default AWS Setup (availability_zones) #3

Closed ghost closed 4 years ago

ghost commented 7 years ago

I've come across this problem, and a google seems to suggest others are too. While something like the following is supposed to get your availability_zones, and use them, it can bail out if it finds a zone without a default subnet:

data "aws_availability_zones" "available" {
  state = "available"
}

I think your book uses 'all' instead? - Neither work.

This was because my account (maybe others, unsure with AWS) had access to us-east-1b, but that particular dc didn't have a default subnet.

I got around this problem using a hardcoded list:

variable "avail_zones" {
  description = "A list of availabilty zones to use:"
  type        = "list"
  default     = ["us-east-1a", "us-east-1d", "us-east-1e"]
}

I don't know if this is the best way to go around the problem (not if you don't like hard-coding things, and who does?) but it was the best I could see initially.


I don't know if it may be worth a note to this effect in the release version of the book?

brikis98 commented 7 years ago

Yes, I've hit this issue before as well. I think AWS recently added some availability zones to existing AWS accounts without adding default subnets for them. Not sure I can get this into the book before it goes to production, but it's a good idea to have the bug filed in this repo.

It may be worth filing a bug (or rather, feature request) with the Terraform folks so that there is a way to select availability zones that have default subnets.

brikis98 commented 4 years ago

This sounds like a Terraform issue and is 3 years old now, so closing.