Skip to content

Commit ef9c85b

Browse files
committed
fix: use -chdir and -upgrade in terraform_validate wrapper
- This tool doesn't clean up any generated lockfiles; if a lockfile already exists (from a previous run), it's possible to get an error like "locked provider registry.terraform.io/hashicorp/google 6.4.0 does not match" - Use Terraform's `-chdir` option rather than `cd`
1 parent a9c4772 commit ef9c85b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

infra/build/developer-tools/build/scripts/task_wrapper_scripts/terraform_validate

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@
1919
# files to validate. This directory is assumed to be a root module.
2020

2121
set -eu
22-
curdir=$(pwd)
23-
cd "${1}"
24-
flock -x /workspace/.terraform.lock -c "terraform init -backend=false >/dev/null"
25-
flock -s /workspace/.terraform.lock -c "terraform validate"
26-
cd "$curdir"
22+
flock -x /workspace/.terraform.lock -c "terraform init -upgrade -chdir=$1 -backend=false >/dev/null"
23+
flock -s /workspace/.terraform.lock -c "terraform -chdir=$1 validate"

0 commit comments

Comments
 (0)