hashicorp / terraform-exec

Terraform CLI commands via Go.
https://pkg.go.dev/github.com/hashicorp/terraform-exec
Mozilla Public License 2.0
661 stars 111 forks source link

Passing In Variables At Runtime #437

Open AdminTurnedDevOps opened 7 months ago

AdminTurnedDevOps commented 7 months ago

Hey All,

Trying to figure out how to pass in variables at runtime. For example:

terraform apply --auto-approve -var name="value" -var location="value"

I set up a Variables interface to pass in the values (setting up the values of the variables by passing them in at runtime. Already have that covered).

        variables := map[string]interface{}{
            "name":                name,
            "resource_group_name": resourceGroupName,
            "location":            location,
            "node_count":          nodeCount,
            "k8s_version":         k8sVersion,
        }

        err = tf.Apply(context.Background())