cycloidio/inframap

How to do when the state is stored in a backend ?

MichaelMure opened this issue · 5 comments

Is there a way to use this tool when the state is stored in a terraform backend like S3 ? There is no .tfstate file in that case.

Thanks :)

Hi @MichaelMure , thanks for raising this issue !

That's a good point to raise. Indeed, Terraform supports multiple backends (S3 included) but the goal of inframap is to only generate graphs from local tfstate (or HCL), it's currently up to the user to provide the tfstate or HCL.

In order to solve your use-case: inframap is able to read the tfstate (or HCL) from the stdin, you could simply make the following:

aws s3 cp s3://bucket/path/to/your/file.tfstate - | inframap generate --tfstate

@MichaelMure we added your question to the FAQ in this PR (#46) https://github.com/cycloidio/inframap#does-inframap-support-terraform-backends-

Thanks for your contribution ! 😉

thanks :)

If using some other backend (such as the http backend) then an alternative approach is:

terraform state pull | inframap generate --tfstate

Thanks @purplepangolin I'm gonna add it to the documentation so it's also easily available for people to use :) BTW if you want you can drop the --tfstate flag as it automatically identifies the type (HCL or State) if you want :)