|
| 1 | +# terraform-variables-generator |
| 2 | + |
| 3 | +Simple Tool for Generate Variables file from Terraform Configuration. It will find all *.tf files in current directory, and generate varibales.tf file, if you already have this file, it will ask to override it. |
| 4 | + |
| 5 | +## Build |
| 6 | + |
| 7 | +```bash |
| 8 | +go build . |
| 9 | +``` |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +```bash |
| 14 | +./terraform-variables-generator |
| 15 | +``` |
| 16 | + |
| 17 | +It will find all *.tf files in current directory, and generate varibales.tf file, if you already have this file, it will ask to override it. |
| 18 | + |
| 19 | +### Example |
| 20 | + |
| 21 | +```text |
| 22 | +resource "aws_vpc" "vpc" { |
| 23 | + cidr_block = "${var.cidr}" |
| 24 | + enable_dns_hostnames = "${var.enable_dns_hostnames}" |
| 25 | + enable_dns_support = "${var.enable_dns_support}" |
| 26 | + |
| 27 | + tags { |
| 28 | + Name = "${var.name}" |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +resource "aws_internet_gateway" "vpc" { |
| 33 | + vpc_id = "${aws_vpc.vpc.id}" |
| 34 | + |
| 35 | + tags { |
| 36 | + Name = "${var.name}-igw" |
| 37 | + } |
| 38 | +} |
| 39 | +``` |
| 40 | + |
| 41 | + Will generate |
| 42 | + |
| 43 | + ```text |
| 44 | + variable "ami" { |
| 45 | + description = "" |
| 46 | +} |
| 47 | + |
| 48 | +variable "instance_type" { |
| 49 | + description = "" |
| 50 | +} |
| 51 | + |
| 52 | +variable "cidr" { |
| 53 | + description = "" |
| 54 | +} |
| 55 | + |
| 56 | +variable "enable_dns_hostnames" { |
| 57 | + description = "" |
| 58 | +} |
| 59 | + |
| 60 | +variable "enable_dns_support" { |
| 61 | + description = "" |
| 62 | +} |
| 63 | + |
| 64 | +variable "name" { |
| 65 | + description = "" |
| 66 | +} |
| 67 | + ``` |
| 68 | + |
| 69 | +## Tests |
| 70 | + |
| 71 | +Run tests and linter |
| 72 | + |
| 73 | +```bash |
| 74 | +go test -v -race ./... |
| 75 | +golint -set_exit_status $(go list ./...) |
| 76 | +``` |
0 commit comments