brikis98 / terraform-up-and-running-code

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

Simple examples assume that account has default VPC #26

Closed PSLLSP closed 4 years ago

PSLLSP commented 5 years ago

Simple examples silently assume that account (region) has default VPC. Simple examples use us-east-1, the oldest AWS region, so there is a chance that older account is "EC2-clasic" and doesn't have default VPC and related infrastructure. That is difficult for beginner to fix these issues.

https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html

That is my case, simple examples fail when I try them in region us-east-1. It is "difficult" to modify examples to use vpc-id, etc. The easiest workaround is to use different region, like us-east-2 (Ohio), that should have default VPC because it was added recently and default VPC is always there.

brikis98 commented 5 years ago

Well, I'm not sure it's "silent" as the book has a clear warning early on that we use the Default VPC to try to keep the examples simple.

That said, using a different region than us-east-1 does seem like a clever way to increase the odds that the VPC exists. I'll keep it in mind for the 2nd edition of the book, though a PR to make the change now is very welcome!

brikis98 commented 4 years ago

This issue was fixed in Terraform: Up & Running, 2nd edition, which came out in 2019, and uses us-east-2 as the default region. There are also clear warnings/instructions about what to do if you don't have a default VPC.