driftctl icon indicating copy to clipboard operation
driftctl copied to clipboard

Auto discovery of the state file from terraform backend block

Open sjourdan opened this issue 5 years ago • 4 comments

Description

As suggested by @Gary-Armstrong, to be able to specify a --from tfstate is good enough, but by reading the right terraform file we could get the same information and build the option automatically for the user:

terraform {
  backend "s3" {
    bucket = "the-bucket-name"
    key    = "some-directory-name"
    region = "us-east-1"
    dynamodb_table = "some-statelock"
  }
}

Sidenote: it should also work dynamically for people with different workspaces.

⚠️ this feature breaks the initial assumption that driftctl runs without any need to access the TF HCL code. ⚠️ this feature may make the multi-state feature less obvious

Example

sjourdan avatar Jan 07 '21 19:01 sjourdan

We should dig into this and think about it with terraform code as a potential IaC source in mind. This is something potentially bigger than it looks

eliecharra avatar Jan 07 '21 23:01 eliecharra

Consider also the same configurations can be given via terraform Environment variables too. Which is how I mainly use terraform (backend bucket config is an env var)

troxil avatar Jan 21 '21 01:01 troxil

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 23 '21 15:03 stale[bot]

This was done in #1555

sundowndev avatar Nov 14 '22 08:11 sundowndev