https://github.com/chorusone/saltstack-module-tfstate
Saltstack module to use contents of Terraform's tfstate file to use in pillar
https://github.com/chorusone/saltstack-module-tfstate
module saltstack terraform
Last synced: about 1 month ago
JSON representation
Saltstack module to use contents of Terraform's tfstate file to use in pillar
- Host: GitHub
- URL: https://github.com/chorusone/saltstack-module-tfstate
- Owner: ChorusOne
- License: apache-2.0
- Created: 2018-06-30T07:44:29.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-12T13:48:23.000Z (over 7 years ago)
- Last Synced: 2025-04-09T09:32:12.781Z (about 1 year ago)
- Topics: module, saltstack, terraform
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 24
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# saltstack-module-tfstate
Saltstack module to access attributes of dynamically created assets directly from Terraform's tfstate file for use in pillar.
## Installation
1. To use this module, you must ensure that it is available from your master's fileserver root; the easiest way to acheive this is to utilize `gitfs` by adding the following to your /etc/salt/master file:
```
fileserver_backends:
- root
- gitfs
gitfs_remotes:
- https://github.com/ChorusOne/saltstack-module-tfstate.git
```
2. and in the same file, for s3 backend:
```
mytfstate: ##
driver: terraform
backend: s3
bucket: my-bucket-name
key: my-tfstate-file.tfstate
```
or, for file-based:
```
mytfstate:
driver: terraform
backend: file
tfstatefile: /opt/terraform/tfstate.tfstate
```
3. Restart `salt-master`
4. Run `sudo salt-run fileserver.update`
5. Run `sudo salt-run saltutil.sync_all`, and look for `sdb.terraform` in the output.
You are ready to use the `sdb:///./` syntax in your pillar:
```
...
ip: sdb://mytfstate/aws_instance.host/public_ip # for resources created in the environment root
...
ip: sdb://mytfstate/module.my_module.aws_instance.host/private_ip # for resources created by a module
...
{% if salt['sdb.get']('sdb://mytfstate/aws_instance.host/public_ip') == '10.0.0.1' %}
...
{% endif %}
```