0

Is there way to set a value for vars.tfvars by passing a string parameter from Jenkins?

Jenkins sting parameter. This is groovy scripeted pipeline

enter image description here

cat vars.tfvars

enter image description here

cat variables.tf

enter image description here

1 Answers1

1

Dynamic values should be passed through the command line. And you can make use of .tfvars file and command-line arguments at the same time like

terraform apply -var-file=vars.tfvars -var domain_name=test

and command line value will always take precedence over the value given in .tfvars file

so in the case of groovy, it can go like

sh 'terraform apply -var-file=vars.tfvars -var domain_name=${domain_name}'