brikis98 / terraform-up-and-running-code

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

Why this web server cluster definition doesn't have backend configuration? #77

Closed sdzhangtao closed 2 years ago

sdzhangtao commented 2 years ago

This is really a question, I just don't know how to label it as a question I am reading chapter three, wondering whether following file is complete or not. It doesn't have backend configuration like mysql does. https://github.com/brikis98/terraform-up-and-running-code/blob/master/code/terraform/03-terraform-state/file-layout-example/stage/services/webserver-cluster/main.tf

Thanks Tao

ncthanh2000 commented 2 years ago

Either that means he intended for that to use the local backend, or just forgot to add a s3 backend to it. I just reused the s3 backend

brikis98 commented 2 years ago

For real, production code or anything you work on with more than one person, yes, you'll want a backend configuration for all modules. In the book, where it's code just for learning & testing for one person, I typically only included the backend in cases where I was demonstrating something specifically about Terraform state: e.g., showing how backend configs work, or showing how to read another module's state using terraform_remote_state.