Get a list of available state files #683
Replies: 2 comments
-
Hi @designermonkey can you explain the use case? If you are looking to read outputs of your resources (a vpc id, for example), an output parameter is a better choice. |
Beta Was this translation helpful? Give feedback.
-
Hi @designermonkey, This is a great question and is a good use case as to why having a good naming/pathing convention really helps. There is a great blog post by Yevgeniy Brikman that covers "Isolation via file layout" (feel free to skip to that section of the post) which is what I always try to follow in my Terraform projects. It looks like your state file layout follows a similar pattern. A single manifest files typically wouldn't be needed if the state files follow a well known pattern and naming convention. This way I can templatize the path to the state file that will work across environment lifecycles and use cases. It can be as simple or complex as needed depending on the resource footprint. For example, if I have an Ansible Role that is going to configure my web-server with a DB connection string, then I can templatize the path to the state file to get the DB info (or anything else that I need from Terraform outputs/state): This does depend on "how" the state files are being split and how the overall project structure is. |
Beta Was this translation helpful? Give feedback.
-
I'm following best practices for splitting state out into multiple files which results in the following in my s3 bucket:
I need to use these files to access output values in my ansible project. I can easily access the files themselves, but the issue I have is knowing what file is where. I have a question:
Has anyone got good advice on how to get a manifest of all the state files, maybe as a terraform module I can run, which stores a state file at
/my-project/manifest.terraform.tfstate
for example?Maybe I'm barking up the wrong tree and need to rethink how I get the state in ansible...
Tracked in ticket #109992
Beta Was this translation helpful? Give feedback.
All reactions