Skip to content

Commit

Permalink
Add support for planning destroys (#24)
Browse files Browse the repository at this point in the history
* Add support for planning destroys

* Forgot to build

* Do not use global ncc to build

* Build using "npm run build"
  • Loading branch information
tun0 authored Feb 22, 2022
1 parent 4438296 commit 95d037a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ inputs:
required: false
description: Limit the number of concurrent operations during plan/apply
default: '10'
terraform_plan_destroy:
required: false
description: Whether to run `terraform plan -destroy` instead of `terraform plan`
default: 'false'
terraform_targets:
required: false
description: A multiline string containing targets that should be passed to terraform (one per line)
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5514,6 +5514,7 @@ async function terraform(args) {
let terraformDoDestroy = core.getBooleanInput('terraform_do_destroy');
const terraformLock = core.getBooleanInput('terraform_lock');
const terraformParallelism = core.getInput('terraform_parallelism');
const terraformPlanDestroy = (terraformDoDestroy || core.getBooleanInput('terraform_plan_destroy')) ? '-destroy' : '';
const terraformTargets = core.getMultilineInput('terraform_targets').map((target) => `-target=${target}`);
const terraformVariables = core.getInput('terraform_variables');
const terraformWorkspace = core.getInput('terraform_workspace');
Expand Down Expand Up @@ -5646,7 +5647,7 @@ async function terraform(args) {
}

core.startGroup('Run terraform plan');
const tfp = await terraform(['plan', `-lock=${terraformLock}`, `-parallelism=${terraformParallelism}`, '-out=terraform.plan'].concat(terraformTargets));
const tfp = await terraform(['plan', `-lock=${terraformLock}`, `-parallelism=${terraformParallelism}`, '-out=terraform.plan'].concat(terraformTargets).concat(terraformPlanDestroy));
core.endGroup();
if (tfp.status > 0) {
tf_plan = status_failed;
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async function terraform(args) {
let terraformDoDestroy = core.getBooleanInput('terraform_do_destroy');
const terraformLock = core.getBooleanInput('terraform_lock');
const terraformParallelism = core.getInput('terraform_parallelism');
const terraformPlanDestroy = (terraformDoDestroy || core.getBooleanInput('terraform_plan_destroy')) ? '-destroy' : '';
const terraformTargets = core.getMultilineInput('terraform_targets').map((target) => `-target=${target}`);
const terraformVariables = core.getInput('terraform_variables');
const terraformWorkspace = core.getInput('terraform_workspace');
Expand Down Expand Up @@ -175,7 +176,7 @@ async function terraform(args) {
}

core.startGroup('Run terraform plan');
const tfp = await terraform(['plan', `-lock=${terraformLock}`, `-parallelism=${terraformParallelism}`, '-out=terraform.plan'].concat(terraformTargets));
const tfp = await terraform(['plan', `-lock=${terraformLock}`, `-parallelism=${terraformParallelism}`, '-out=terraform.plan'].concat(terraformTargets).concat(terraformPlanDestroy));
core.endGroup();
if (tfp.status > 0) {
tf_plan = status_failed;
Expand Down

0 comments on commit 95d037a

Please sign in to comment.