Skip to content

Commit 8c922e1

Browse files
author
Sean Thomas
committed
Fix unbound variable error in migrate-s3-locking script
The --reinit flag crashes with "unbound variable" when a module has no matching .tfvars file, because bash nounset treats an empty array expansion as unbound. Use the ${arr[@]+...} idiom to safely expand.
1 parent 8c3b34b commit 8c922e1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/migrate-terraform-state-locking-to-s3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ if [[ "${reinit}" == true ]]; then
139139
if [ -f "${tf_vars_file}" ]; then
140140
tf_vars_args+=("-var-file=${config_name}.tfvars")
141141
fi
142-
if ! terraform -chdir="${module_dir}" plan -input=false "${tf_vars_args[@]}"; then
142+
if ! terraform -chdir="${module_dir}" plan -input=false ${tf_vars_args[@]+"${tf_vars_args[@]}"}; then
143143
echo " ERROR: terraform plan failed for ${module_dir} ${config_name}"
144144
errors=$((errors + 1))
145145
continue

0 commit comments

Comments
 (0)