Skip to content

heptaliane/tffreeze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tffreeze

tffreeze is the tool to substitute variables in the HCL files.

Usage

tffreeze [OPTION]... [FILE]...

Substitute HCL files with tfvars

You can substitute variables with .tfvars file.

tffreeze -var-file <tfvars file> [FILE]...

Example

When you run tffreeze with "main.tf" and "variable.tfvars", you can get substituted file named "main.freeze.tf".

tffreeze -var-file variables.tfvars main.tf

main.tf

resource "google_compute_instance" "default" {
    name         = var.instance_name
    machine_type = "n2-standard-${var.cpus}"
    zone         = var.zone

    tags = var.tags

    boot_disk {
        initialize_params {
            image  = var.disk_image
            labels = var.disk_labels
        }
    }
}

variables.tf

instance_name = "default-instance"
cpus          = 2

tags = ["foo", "bar"]

disk_labels = {
    baz = "qux"
}

main.freeze.tf

resource "google_compute_instance" "default" {
    name         = "default-instance"
    machine_type = "n2-standard-2"
    zone         = var.zone

    tags = ["foo", "bar"]

    boot_disk {
        initialize_params {
            image  = var.disk_image
            labels =  {
                baz = "qux"
            }
        }
    }
}

About

Substitute HCL file variables

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages