Skip to main content

Pydantic to Terraform

This library converts Pydantic Models into Terraform Variables.

Usage

This needs to be installed in the same virtual environment as the Models that it is converting. Once installed a CLI tool, py2tf, will be available in the environment.

For example, to generate a variables file for the RDS ParameterValidation class-

robert@Roberts-MacBook-Pro terraform-aws-core % py2tf modules.rds.validation.parameters:ParameterValidation

The command will output the following to stdout:

variable "type" {
  type = string
  default = null
}

variable "pit_identifier" {
  type = string
  default = null
}

variable "tags" {
  type = map(any)
  default = {}
}

variable "name" {
  type = string
  validation {
    # Automatically Generated from Rule: minlength
    condition     = length(var.name) >= 1
    error_message = "Field should not be less than 1 characters"
  }
  validation {
    # Automatically Generated from Rule: maxlength
    condition     = length(var.name) <= 63
    error_message = "Field should not be larger than 63 characters"
  }
  validation {
    # Automatically Generated from Rule: pattern
    condition     = length(regexall("^(?!.*--)[a-zA-Z][A-Za-z0-9.-]+(?<!-)$", var.name)) > 0
    error_message = "Field does not match regex pattern ^(?!.*--)[a-zA-Z][A-Za-z0-9.-]+(?<!-)$"
  }
}

variable "vpc_name" {
  type = string
}

variable "engine" {
  type = string
  validation {
    # Automatically Generated from Rule: minlength
    condition     = length(var.engine) >= 1
    error_message = "Field should not be less than 1 characters"
  }
}

variable "engine_version" {
  type = string
  validation {
    # Automatically Generated from Rule: minlength
    condition     = length(var.engine_version) >= 1
    error_message = "Field should not be less than 1 characters"
  }
}

variable "is_public" {
  type = bool
  default = false
}

Next Steps

At the moment this does not generate validation rules (min/max length, regex, etc).

Metadata

Release files for py2tf 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py2tf 0.4.4
File Size Uploaded Provenance Actions
py2tf-0.4.4.tar.gz 8.8 kB Without provenance Details for py2tf-0.4.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py2tf 0.4.4
File Interpreter ABI Platform Actions
py2tf-0.4.4-py3-none-any.whl Python 3 none any Details for py2tf-0.4.4-py3-none-any.whl

Total release size: 19.3 kB

Release files / py2tf-0.4.4.tar.gz

Download URL py2tf-0.4.4.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a28a4991deec64e670cec0e46f5244b102914560b6176ba922d948bab48c1f57
BLAKE2b-256 checksum
How to use checksums
feff0536be20d2b709c8f593f4d68f09890af2b224897f3be84cffa7622c5883
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / py2tf-0.4.4-py3-none-any.whl

Download URL py2tf-0.4.4-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34de8d56e685206d65d99e46dd2640b5766c76a6a822ee19eb0bda2f90beeddd
BLAKE2b-256 checksum
How to use checksums
a6cbf854256236b331e9757e773ac55bbf38f18f0ce6cc124a2a2e3a37bbbdb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Security for py2tf 0.4.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page