Skip to content

Commit

Permalink
Add support for terraform init with backend-config option inside Terr…
Browse files Browse the repository at this point in the history
…aformClient
  • Loading branch information
alfespa17 committed May 14, 2021
1 parent 5d00e85 commit 4ef21cb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion terraform-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.0.4</revision>
<revision>0.0.5</revision>
<maven.deploy.skip>false</maven.deploy.skip>
<okhttp.version>4.9.1</okhttp.version>
<commons-io.version>2.8.0</commons-io.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand All @@ -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<String, String> environmentVariables;
private HashMap<String, String> terraformParameters;
Expand Down Expand Up @@ -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<String, String> entry : this.getTerraformParameters().entrySet()) {
launcher.appendCommands("--var", entry.getKey().concat("=").concat(entry.getValue()));
Expand Down Expand Up @@ -198,5 +203,13 @@ public HashMap<String, String> getTerraformParameters() {
public void setTerraformParameters(HashMap<String, String> terraformParameters) {
this.terraformParameters = terraformParameters;
}

public String getBackendConfig() {
return backendConfig;
}

public void setBackendConfig(String backendConfig) {
this.backendConfig = backendConfig;
}
}

2 changes: 1 addition & 1 deletion terraform-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.0.4</revision>
<revision>0.0.5</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion terraform-spring-boot-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.0.4</revision>
<revision>0.0.5</revision>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion terraform-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>0.0.4</revision>
<revision>0.0.5</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

Expand Down

0 comments on commit 4ef21cb

Please sign in to comment.