Convert Pydantic Models into Terraform Variables
Project description
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 = len(var.name) >= 1
error_message = "Field should not be less than 1 characters"
}
validation {
# Automatically Generated from Rule: maxlength
condition = len(var.name) <= 63
error_message = "Field should not be larger than 63 characters"
}
validation {
# Automatically Generated from Rule: pattern
condition = len(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 = len(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 = len(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).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py2tf-0.1.1.tar.gz
(7.5 kB
view details)
Built Distribution
py2tf-0.1.1-py3-none-any.whl
(8.5 kB
view details)
File details
Details for the file py2tf-0.1.1.tar.gz
.
File metadata
- Download URL: py2tf-0.1.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c9e3f7184181418bc06fdfac09913acb885b96a080c0429850afa30bc80ce37 |
|
MD5 | 12c8d32f0c64f9698e02fe6dc1af0068 |
|
BLAKE2b-256 | 821daadc8a070748f9c63b355208198bccf9b822a8f08565d58f1778001018e1 |
File details
Details for the file py2tf-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: py2tf-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11b9d3e8cc04d2607de7e9bfa87e90970e9cea1f390f97300223adca17043c19 |
|
MD5 | c537b3fbb8bf82fe49d0b6345ed64c81 |
|
BLAKE2b-256 | d599d1cae744cae62a957dacf405731807bf450b66d3b810c5d0a58e0db48988 |