Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrewthetechie/tf-vars-to-pydantic
Convert the variables.tf from your terraform module to a Pydantic Model
https://github.com/andrewthetechie/tf-vars-to-pydantic
Last synced: about 1 month ago
JSON representation
Convert the variables.tf from your terraform module to a Pydantic Model
- Host: GitHub
- URL: https://github.com/andrewthetechie/tf-vars-to-pydantic
- Owner: andrewthetechie
- License: mit
- Created: 2023-03-04T05:28:25.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-11T02:20:09.000Z (about 2 months ago)
- Last Synced: 2024-11-16T22:38:48.872Z (about 2 months ago)
- Language: Python
- Size: 266 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## Features
- Read a Terraform Variables HCL file (variables.tf) and create a Pydantic model from it
- Interpret complex data types (list(string), etc) into Python data types
- Interpret object data types into sub models
- Does not currently support terraform input validation## Requirements
- Python ^3.11
- Pydantic ^1.10.x
- python-hcl2 ^4.3.x## Installation
You can install _Tf Vars To Pydantic_ via [pip] from [PyPI]:
```console
pip install tf-vars-to-pydantic
```## Usage
Assuming you have a tf vars file that looks like:
```
variable "foo" {
description = "String variable"
type = string
}variable "bar" {
description = "String variable with default"
type = number
}variable "baz" {
type = list(string)
}variable "qux" {
description = "Boolean variable"
default = true
type = bool
}
``````python
from tf_vars_to_pydantic import convert_file
TFVarsModel = convert_file(path="./tests/fixtures/simple.tf", model_name="TFVarsModel")
tfvars_as_pydantic = TFVarsModel(foo="test", bar=7.2, baz=['boop', 'bing', 'bong'])
print(tfvars_as_pydantic)
# foo='test' bar=7.2 baz=['boop', 'bing', 'bong'] qux=True
```## Contributing
Contributions are very welcome.
To learn more, see the [Contributor Guide].## License
Distributed under the terms of the [MIT license][license],
_Tf Vars To Pydantic_ is free and open source software.## Issues
If you encounter any problems,
please [file an issue] along with a detailed description.[license]: https://github.com/andrewthetechie/tf-vars-to-pydantic/blob/main/LICENSE
[contributor guide]: https://github.com/andrewthetechie/tf-vars-to-pydantic/blob/main/CONTRIBUTING.md## Contributors