https://github.com/levsh/terrapy
Python to Terraform converter
https://github.com/levsh/terrapy
cloud-management infrastucture-as-code python terraform
Last synced: 7 months ago
JSON representation
Python to Terraform converter
- Host: GitHub
- URL: https://github.com/levsh/terrapy
- Owner: levsh
- License: mit
- Created: 2020-10-24T16:29:54.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-24T16:39:35.000Z (almost 5 years ago)
- Last Synced: 2025-01-17T17:16:46.666Z (9 months ago)
- Topics: cloud-management, infrastucture-as-code, python, terraform
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terrapy
Python to Terraform converterCreate main.py file
```python
from terrapy import Item, Planplan = Plan()
plan += Item(
"terraform",
required_version='">= 0.13"',
)plan += Item(
"variable",
"test_variable",
type="list(object({one=number, two=number}))",
default=[{"one": 1, "two": 2}],
)plan += Item("provider", "docker", host='"unix:///var/run/docker.sock"')
plan += Item("resource", "docker_container", "foo", image='"redis"', name='"foo"')
plan += Item("module", "module_a", source='"./module_a"')plan += Item("output", "container_foo_id", value="docker_container.foo.id")
```
Then run
```
$ terrapy generate -u
$ terraform validate
``````
$ terrapy generate -h
usage: terrapy generate [-h] [-u] [DIR]Generate terraform plans
positional arguments:
DIR directory with root main.py (default: current directory)optional arguments:
-h, --help show this help message and exit
-u, --upgrade run 'terraform 0.13upgrade' command for each module
```