From 216c10cb7efb72c42b17272a0c9151b06805ce8d Mon Sep 17 00:00:00 2001 From: danilo Date: Fri, 5 Aug 2022 09:07:51 +0200 Subject: [PATCH] Add backend-config option (#28) * add backend-config option * style fix * build * remove reconfigure arg * update logic Co-authored-by: Ruben Laban <5331085+tun0@users.noreply.github.com> * build Co-authored-by: Ruben Laban <5331085+tun0@users.noreply.github.com> --- action.yaml | 3 +++ dist/index.js | 4 +++- index.js | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 7c68e133..a96b6f21 100644 --- a/action.yaml +++ b/action.yaml @@ -13,6 +13,9 @@ inputs: google_credentials: required: true description: Google credentials + terraform_backend: + required: false + description: Location of a terraform backend configuration file terraform_directory: required: false description: Location of terraform manifests diff --git a/dist/index.js b/dist/index.js index ef386710..09b98f45 100644 --- a/dist/index.js +++ b/dist/index.js @@ -12651,6 +12651,7 @@ async function terraform(terraformDirectory, args) { } (async () => { + const terraformBackend = core.getInput('terraform_backend'); let terraformDoApply = core.getBooleanInput('terraform_do_apply'); let terraformDoDestroy = core.getBooleanInput('terraform_do_destroy'); const terraformDirectory = core.getInput('terraform_directory'); @@ -12716,7 +12717,8 @@ async function terraform(terraformDirectory, args) { } core.startGroup('Run terraform init'); - const tfi = await terraform(terraformDirectory, ['init']); + let tfi_args = terraformBackend ? ['-backend-config=' + terraformBackend] : []; + const tfi = await terraform(terraformDirectory, ['init'].concat(tfi_args)); core.endGroup(); if (tfi.status > 0) { tf_init = status_failed; diff --git a/index.js b/index.js index c991233a..876cfd7d 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,7 @@ async function terraform(terraformDirectory, args) { } (async () => { + const terraformBackend = core.getInput('terraform_backend'); let terraformDoApply = core.getBooleanInput('terraform_do_apply'); let terraformDoDestroy = core.getBooleanInput('terraform_do_destroy'); const terraformDirectory = core.getInput('terraform_directory'); @@ -101,7 +102,8 @@ async function terraform(terraformDirectory, args) { } core.startGroup('Run terraform init'); - const tfi = await terraform(terraformDirectory, ['init']); + let tfi_args = terraformBackend ? ['-backend-config=' + terraformBackend] : []; + const tfi = await terraform(terraformDirectory, ['init'].concat(tfi_args)); core.endGroup(); if (tfi.status > 0) { tf_init = status_failed;