From 4ef21cbaddcf77382f65cce54d954861841f7845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfredo=20Espa=C3=B1a?= Date: Fri, 14 May 2021 16:42:07 -0600 Subject: [PATCH] Add support for terraform init with backend-config option inside TerraformClient --- terraform-client/pom.xml | 2 +- .../org/azbuilder/terraform/TerraformClient.java | 15 ++++++++++++++- terraform-spring-boot-autoconfigure/pom.xml | 2 +- terraform-spring-boot-samples/pom.xml | 2 +- terraform-spring-boot-starter/pom.xml | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/terraform-client/pom.xml b/terraform-client/pom.xml index a3529da..fac42f4 100644 --- a/terraform-client/pom.xml +++ b/terraform-client/pom.xml @@ -19,7 +19,7 @@ UTF-8 - 0.0.4 + 0.0.5 false 4.9.1 2.8.0 diff --git a/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java b/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java index 6186072..2712900 100644 --- a/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java +++ b/terraform-client/src/main/java/org/azbuilder/terraform/TerraformClient.java @@ -1,7 +1,6 @@ package org.azbuilder.terraform; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.SystemUtils; import java.io.*; import java.nio.file.*; @@ -17,6 +16,7 @@ public class TerraformClient implements AutoCloseable { private File workingDirectory; private boolean inheritIO; private String terraformVersion; + private String backendConfig; private TerraformDownloader terraformDownloader; private HashMap environmentVariables; private HashMap terraformParameters; @@ -155,6 +155,11 @@ private ProcessLauncher getTerraformLauncher(TerraformCommand command) throws IO } switch (command) { + case init: + if(getBackendConfig() !=null){ + launcher.appendCommands("-backend-config=".concat(this.getBackendConfig())); + } + break; case plan: for (Map.Entry entry : this.getTerraformParameters().entrySet()) { launcher.appendCommands("--var", entry.getKey().concat("=").concat(entry.getValue())); @@ -198,5 +203,13 @@ public HashMap getTerraformParameters() { public void setTerraformParameters(HashMap terraformParameters) { this.terraformParameters = terraformParameters; } + + public String getBackendConfig() { + return backendConfig; + } + + public void setBackendConfig(String backendConfig) { + this.backendConfig = backendConfig; + } } diff --git a/terraform-spring-boot-autoconfigure/pom.xml b/terraform-spring-boot-autoconfigure/pom.xml index d4866a9..bde4b5a 100644 --- a/terraform-spring-boot-autoconfigure/pom.xml +++ b/terraform-spring-boot-autoconfigure/pom.xml @@ -18,7 +18,7 @@ UTF-8 - 0.0.4 + 0.0.5 false diff --git a/terraform-spring-boot-samples/pom.xml b/terraform-spring-boot-samples/pom.xml index 68113f4..2b64138 100644 --- a/terraform-spring-boot-samples/pom.xml +++ b/terraform-spring-boot-samples/pom.xml @@ -18,7 +18,7 @@ UTF-8 - 0.0.4 + 0.0.5 true diff --git a/terraform-spring-boot-starter/pom.xml b/terraform-spring-boot-starter/pom.xml index 7283e9c..49863ee 100644 --- a/terraform-spring-boot-starter/pom.xml +++ b/terraform-spring-boot-starter/pom.xml @@ -13,7 +13,7 @@ UTF-8 - 0.0.4 + 0.0.5 false