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

Example using tfvars -> main -> modules #18

Closed jedierik20 closed 4 years ago

jedierik20 commented 7 years ago

I'm sure I'm missing one singular piece of logic to connect these dots, but I'm trying to create the mechanism described in the section regardling "Larger Teams May Need to Use a Development Pipeline". Specifically I've got tfvars in my specific environment dirs (aka: Figure 6-4). I have my source defined in that tfvars, but init, or get, or plan for that matter, are not downloading anything. It's a constant "no configuration files present".

However, as I wrote this, I finally solved the problem. The key issue deals with moving to the terraform init method. In your book, although you stated that we would need to make a wrapper to perform terraform init, it was a small logic leap that I missed which is the terraform init /source-dir /target-dir mechanism.

I was assuming (incorrectly) that init should be fed the tfvars and realize/use the source. this is not the case, and init needs to be done "manually" (seperately from tfvars) using the "SAME SOURCE" and choosing our tfvars dir as the destination (or not, but that would make the plan and apply much more difficult command lines).

brikis98 commented 7 years ago

Check out https://github.com/gruntwork-io/terragrunt. It does exactly what I describe in the book :)

grig-tar commented 6 years ago

So, did I understood correctly, example from the book not works without a terragrunt?

brikis98 commented 6 years ago

The book outlines the basic approach to using pipelines. That approach is not natively supported by Terraform itself yet, so you have to implement it yourself. There are many ways to do it. One way is to use Terragrunt. Another is to use S3 as described by Kief Morrison.

jedierik20 commented 6 years ago

No - I don't believe there was specific code in the book to cover this - and honestly, I'm using all of the advanced topics covered - DRY, modular, remote state, sub-dirs, live layouts, larger teams, etc. For this issue - i think Yevgeniy is spot on, and the way that I'm doing pipelines is using Terragrunt - which is an excellent wrapper for doing these advanced functions, but is slightly outside the scope of the book. Besides, I am quite certain, if you run into issues in this area, and add to this thread, someone (maybe even the author himself) would jump in and help (he did several times for me!).

brikis98 commented 4 years ago

I believe the question here was answered. Closing this ~3 year old issue.