Skip to main content

Tf Vars To Pydantic

Project description

Latest Commit GitHub release (latest by date)
GitHub Workflow Status Test and Lint (branch) Contributors
Package version

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]:

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
}
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, 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.

Contributors

Andrew
Andrew

💻 ⚠️ 📖

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tf_vars_to_pydantic-0.1.2.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

tf_vars_to_pydantic-0.1.2-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page