Skip to content

Commit

Permalink
feat: add option for init command to upgrade providers (#102)
Browse files Browse the repository at this point in the history
Co-authored-by: marboledacci <mateo.arboleda@circleci.com>
  • Loading branch information
0x63lv and marboledacci authored Sep 26, 2024
1 parent ef3478b commit b91fd52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/commands/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ parameters:
description: Configure a custom timeout limit
type: string
default: 10m
upgrade:
description: "Install the latest terraform module and provider versions"
type: boolean
default: false

steps:
- run:
Expand All @@ -38,4 +42,5 @@ steps:
TF_PARAM_BACKEND_CONFIG: << parameters.backend_config >>
TF_PARAM_BACKEND_CONFIG_FILE: << parameters.backend_config_file >>
TF_PARAM_CLI_CONFIG_FILE: << parameters.cli_config_file >>
TF_PARAM_UPGRADE: << parameters.upgrade >>
command: <<include(scripts/init.sh)>>
5 changes: 5 additions & 0 deletions src/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ if [[ -n "${TF_PARAM_BACKEND_CONFIG}" ]]; then
INIT_ARGS="$INIT_ARGS -backend-config=$(eval echo "$config")"
done
fi

if [[ "${TF_PARAM_UPGRADE}" = true ]]; then
INIT_ARGS="$INIT_ARGS -upgrade"
fi

export INIT_ARGS
# shellcheck disable=SC2086
terraform -chdir="$module_path" init -input=false -backend=$backend $INIT_ARGS

0 comments on commit b91fd52

Please sign in to comment.