|
8 | 8 | ## |
9 | 9 | # Set Script Version |
10 | 10 | ## |
11 | | -readonly script_ver="1.8.0"; |
| 11 | +readonly script_ver="1.8.1"; |
12 | 12 |
|
13 | 13 | ## |
14 | 14 | # Standardised failure function |
@@ -399,13 +399,16 @@ fi; |
399 | 399 | pushd "${component_path}"; |
400 | 400 | readonly component_name=$(basename ${component_path}); |
401 | 401 |
|
402 | | -# Check for presence of tfenv (https://github.com/kamatama41/tfenv) |
403 | | -# and a .terraform-version file. If both present, ensure required |
404 | | -# version of terraform for this component is installed automagically. |
405 | | -tfenv_bin="$(which tfenv 2>/dev/null)"; |
406 | | -if [[ -n "${tfenv_bin}" && -x "${tfenv_bin}" && -f .terraform-version ]]; then |
407 | | - ${tfenv_bin} install; |
408 | | -fi; |
| 402 | +# install terraform |
| 403 | +# verify terraform version matches .tool-versions |
| 404 | +echo ${PWD} |
| 405 | +tool_version=$(grep "terraform " .tool-versions | cut -d ' ' -f 2) |
| 406 | +asdf plugin-add terraform && asdf install terraform "${tool_version}" |
| 407 | +current_version=$(terraform --version | head -n 1 | cut -d 'v' -f 2) |
| 408 | + |
| 409 | +if [ -z "${current_version}" ] || [ "${current_version}" != "${tool_version}" ]; then |
| 410 | + error_and_die "Terraform version mismatch. Expected: ${tool_version}, Actual: ${current_version}" |
| 411 | +fi |
409 | 412 |
|
410 | 413 | # Regardless of bootstrapping or not, we'll be using this string. |
411 | 414 | # If bootstrapping, we will fill it with variables, |
@@ -536,26 +539,24 @@ fi; |
536 | 539 | [ -f "${dynamic_file_path}" ] && tf_var_file_paths+=("${dynamic_file_path}"); |
537 | 540 |
|
538 | 541 | # Warn on duplication |
539 | | -if [ ${#tf_var_file_paths[@]} -gt 0 ]; then |
540 | | - duplicate_variables="$(cat "${tf_var_file_paths[@]}" | sed -n -e 's/\(^[a-zA-Z0-9_\-]\+\)\s*=.*$/\1/p' | sort | uniq -d)"; |
541 | | - [ -n "${duplicate_variables}" ] \ |
542 | | - && echo -e " |
543 | | - ################################################################### |
544 | | - # WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING # |
545 | | - ################################################################### |
546 | | - The following input variables appear to be duplicated: |
547 | | -
|
548 | | - ${duplicate_variables} |
549 | | -
|
550 | | - This could lead to unexpected behaviour. Overriding of variables |
551 | | - has previously been unpredictable and is not currently supported, |
552 | | - but it may work. |
553 | | -
|
554 | | - Recent changes to terraform might give you useful overriding and |
555 | | - map-merging functionality, please use with caution and report back |
556 | | - on your successes & failures. |
557 | | - ###################################################################"; |
558 | | -fi |
| 542 | +duplicate_variables="$(cat "${tf_var_file_paths[@]}" | sed -n -e 's/\(^[a-zA-Z0-9_\-]\+\)\s*=.*$/\1/p' | sort | uniq -d)"; |
| 543 | +[ -n "${duplicate_variables}" ] \ |
| 544 | + && echo -e " |
| 545 | +################################################################### |
| 546 | +# WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING # |
| 547 | +################################################################### |
| 548 | +The following input variables appear to be duplicated: |
| 549 | +
|
| 550 | +${duplicate_variables} |
| 551 | +
|
| 552 | +This could lead to unexpected behaviour. Overriding of variables |
| 553 | +has previously been unpredictable and is not currently supported, |
| 554 | +but it may work. |
| 555 | +
|
| 556 | +Recent changes to terraform might give you useful overriding and |
| 557 | +map-merging functionality, please use with caution and report back |
| 558 | +on your successes & failures. |
| 559 | +###################################################################"; |
559 | 560 |
|
560 | 561 | # Build up the tfvars arguments for terraform command line |
561 | 562 | for file_path in "${tf_var_file_paths[@]}"; do |
|
0 commit comments