Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use .terraform/terraform.tfstate when local state is unavailable #40

Closed
cbarbour opened this issue Aug 11, 2016 · 3 comments
Closed

Use .terraform/terraform.tfstate when local state is unavailable #40

cbarbour opened this issue Aug 11, 2016 · 3 comments

Comments

@cbarbour
Copy link

cbarbour commented Aug 11, 2016

Description

Feature request.

Currently, terraform inventory checks the current working directory for the terraform.tfstate file. When configured to use a remote state, terraform places the state file in the .terraform/ directory instead.

It would be useful for terraform-inventory to check for .terraform/terraform.tfstate if it doesn't find the state in the root of the terraform configuration. This would make life simpler for folks using remote state, and might help avoid the need to wrap terraform-inventory to pull state from a s3 bucket or other remote location.

Steps to reproduce

  1. Create a S3 bucket for remote state
  2. Configure Terraform to use remote state
  3. Confirm that the state was successfully pushed, and that a copy exists in .terraform
  4. Remove the local state files.

Configuration example

terraform remote config -backend=s3 \
  -backend-config="bucket=myproject-terraform-state" \
  -backend-config="key=myproject/terraform.tfstate" \
  -backend-config="region=us-east-1"

Versions

  • terraform-inventory version '0.6.1'
  • Terraform v0.7.0

Additional information

Remote state include a remote block to preserve the remote configuration. This seems to cause no issues for terraform-inventory. I can confirm that terraform-inventory reads the file just fine.

@adammck
Copy link
Owner

adammck commented Aug 12, 2016

Thanks for the detailed feature request. This is a fantastic idea, which I've taken a stab at in #41. Would you mind taking a look and letting me know if it works for you?

@cbarbour
Copy link
Author

Awesome, thanks! I'll try it today and send my feedback.

@cbarbour
Copy link
Author

The pull request did exactly what I was hoping for. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants