Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optionally apply plan file #74

Merged
merged 2 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/commands/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ parameters:
type: "string"
description: "Path to terraform cli config file"
default: ""
plan:
type: string
description: Optionally provide a plan file to supply to the 'apply' command.
default: ""
timeout:
description: Configure a custom timeout limit
type: string
Expand All @@ -48,4 +52,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_PLAN: <<parameters.plan>>
command: <<include(scripts/apply.sh)>>
5 changes: 5 additions & 0 deletions src/commands/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ parameters:
type: "string"
description: "Path to terraform cli config file"
default: ""
out:
type: string
description: The file path to save your terraform plan to.
default: "plan.out"
timeout:
description: Configure a custom timeout limit
type: string
Expand All @@ -48,4 +52,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_OUT: << parameters.out >>
command: <<include(scripts/plan.sh)>>
5 changes: 5 additions & 0 deletions src/jobs/apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ parameters:
type: "string"
description: "Path to terraform cli config file"
default: ""
plan:
type: string
description: Optionally provide a plan file to supply to the 'apply' command.
default: ""
tag:
description: "Specify the Terraform Docker image tag for the executor"
type: "string"
Expand Down Expand Up @@ -92,6 +96,7 @@ steps:
backend_config: << parameters.backend_config >>
backend_config_file: << parameters.backend_config_file >>
cli_config_file: << parameters.cli_config_file >>
plan: <<parameters.plan>>
timeout: <<parameters.timeout>>
- when:
condition: << parameters.persist-workspace >>
Expand Down
5 changes: 5 additions & 0 deletions src/jobs/plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ parameters:
description: "Specify the Terraform Docker image tag for the executor"
type: "string"
default: "1.0.0" # update commands/install when updating this
out:
type: string
description: The file path to save your terraform plan to.
default: "plan.out"
timeout:
description: "Configure a custom timeout limit"
type: "string"
Expand Down Expand Up @@ -93,6 +97,7 @@ steps:
backend_config: << parameters.backend_config >>
backend_config_file: << parameters.backend_config_file >>
cli_config_file: << parameters.cli_config_file >>
out: << parameters.out >>
timeout: <<parameters.timeout>>
- when:
condition: << parameters.persist-workspace >>
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ else
echo "[INFO] Remote State Backend Enabled"
fi
# shellcheck disable=SC2086
terraform -chdir="$module_path" apply -auto-approve $PLAN_ARGS
terraform -chdir="$module_path" apply -auto-approve $PLAN_ARGS ${TF_PARAM_PLAN}
2 changes: 1 addition & 1 deletion src/scripts/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ if [[ -n "${TF_PARAM_VAR_FILE}" ]]; then
fi
export PLAN_ARGS
# shellcheck disable=SC2086
terraform -chdir="$module_path" plan -input=false -out=plan.out $PLAN_ARGS
terraform -chdir="$module_path" plan -input=false -out=${TF_PARAM_OUT} $PLAN_ARGS