Closed martin-flower closed 4 years ago
update - it seems I was referring to the s3 bucket I created in chapter two. If I use the S3 bucket I created in chapter 3, then the errors go away. It seems to me that the exercises assume that the same bucket is used throughout.
and I get no S3 errors with terraform destroy/init/plan/apply in the stage environment
In the prod environment I get the following message. Is this related to the comment on page 116 the production database doesn't actually exist yet
Error: Unable to find remote state
on ../../../modules/services/webserver-cluster/main.tf line 149, in data "terraform_remote_state" "db":
149: data "terraform_remote_state" "db" {
No stored state was found for the given workspace in the given backend.
What I think this means is that chapter 4 expects (some) things from previous chapters to be there.
Each chapter builds on the examples from previous chapters.
If this is the case, is there a (simple) way of implementing all the pre-requisites
If you skipped previous chapters, use the code from this very repo as your starting point!
I am also confused about using terraform destroy as this sometimes returns an error when attempting to destroy the s3 bucket containing the terraform state.
From the error you listed, I'm guessing you did the following:
apply
in a DB moduleapply
in a web server module that read data from the DB module's state via terraform_remote_state
destroy
in the DB moduleThis is not surprising, as the web server module depends on the DB module, and if you ran destroy
in the DB module first, that dependency is now broken!
To fix it, either:
apply
on the DB module or...terraform_remote_state
references from the web server module and replace them with hard-coded values update - it seems I was referring to the s3 bucket I created in chapter two. If I use the S3 bucket I created in chapter 3, then the errors go away. It seems to me that the exercises assume that the same bucket is used throughout.
Ah, if you deleted the S3 bucket where state was stored, then yes, terraform_remote_state
data sources won't be able to read the state from that bucket!
In the prod environment I get the following message. Is this related to the comment on page 116 the production database doesn't actually exist yet
Correct! The terraform_remote_state
data source is used to read a state file written by another module. In the prod environment, if you never deployed the DB module, then terraform_remote_state
won't be able to read it's state! Deploying such a module is left as an exercise for you, the reader. Hint: deploying the prod DB module should be nearly identical to deploying the stage one.
Thanks Yevgeniy - it's slowly making sense ...
I am reading the book and working using the code from this repository. I am on page 126 and get the error detailed below. What I think this means is that chapter 4 expects (some) things from previous chapters to be there. If this is the case, is there a (simple) way of implementing all the pre-requisites - maybe manually? I am also confused about using terraform destroy as this sometimes returns an error when attempting to destroy the s3 bucket containing the terraform state. Will chapter 4 still work if the bucket is destroyed?