diff --git a/cmd/server.go b/cmd/server.go index 9343220326..6bd97c753a 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -103,6 +103,7 @@ const ( TFDownloadURLFlag = "tf-download-url" VCSStatusName = "vcs-status-name" TFEHostnameFlag = "tfe-hostname" + TFELocalExecutionModeFlag = "tfe-local-execution-mode" TFETokenFlag = "tfe-token" WriteGitCredsFlag = "write-git-creds" WebBasicAuthFlag = "web-basic-auth" @@ -417,6 +418,10 @@ var boolFlags = map[string]boolFlag{ description: "Skips cloning the PR repo if there are no projects were changed in the PR.", defaultValue: false, }, + TFELocalExecutionModeFlag: { + description: "Enable if you're using local execution mode (instead of TFE/C's remote execution mode).", + defaultValue: false, + }, WebBasicAuthFlag: { description: "Switches on or off the Basic Authentication on the HTTP Middleware interface", defaultValue: DefaultWebBasicAuth, diff --git a/cmd/server_test.go b/cmd/server_test.go index 19b1f8e1ea..01c5dcdb6c 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -102,6 +102,7 @@ var testFlags = map[string]interface{}{ SSLKeyFileFlag: "key-file", TFDownloadURLFlag: "https://my-hostname.com", TFEHostnameFlag: "my-hostname", + TFELocalExecutionModeFlag: true, TFETokenFlag: "my-token", VCSStatusName: "my-status", WriteGitCredsFlag: true, diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index 3deea59bfb..9ae12e8f68 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -626,6 +626,12 @@ Values are chosen in this order: If using Terraform Cloud (i.e. you don't have your own Terraform Enterprise installation) no need to set since it defaults to `app.terraform.io`. +* ### `--tfe-local-execution-mode` + ```bash + atlantis server --tfe-local-execution-mode + ``` + Enable if you're using local execution mode (instead of TFE/C's remote execution mode). See [Terraform Cloud](terraform-cloud.html) for more details. + * ### `--tfe-token` ```bash atlantis server --tfe-token="xxx.atlasv1.yyy" diff --git a/runatlantis.io/docs/terraform-cloud.md b/runatlantis.io/docs/terraform-cloud.md index 4cfe521299..a0fb5c13af 100644 --- a/runatlantis.io/docs/terraform-cloud.md +++ b/runatlantis.io/docs/terraform-cloud.md @@ -73,6 +73,10 @@ flag to its hostname. That's it! Atlantis should be able to perform Terraform operations using Terraform Cloud/Enterprise's remote state backend now. +:::warning +If you're using local execution mode for your workspaces, remember to set the +`--tfe-local-execution-mode`. Otherwise you won't see the logs in Atlantis. + :::warning The Terraform Cloud/Enterprise integration only works with the built-in `plan` and `apply` steps. It does not work with custom `run` steps that replace diff --git a/server/server.go b/server/server.go index 047f840eff..31a5a3d2f8 100644 --- a/server/server.go +++ b/server/server.go @@ -351,9 +351,9 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { } var projectCmdOutputHandler jobs.ProjectCommandOutputHandler - // When TFE is enabled log streaming is not necessary. - if userConfig.TFEToken != "" { + if userConfig.TFEToken != "" && !userConfig.TFELocalExecutionMode { + // When TFE is enabled and using remote execution mode log streaming is not necessary. projectCmdOutputHandler = &jobs.NoopProjectOutputHandler{} } else { projectCmdOutput := make(chan *jobs.ProjectCmdOutputLine) diff --git a/server/user_config.go b/server/user_config.go index cab3d8d9f5..8c3674b6a1 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -85,6 +85,7 @@ type UserConfig struct { SSLKeyFile string `mapstructure:"ssl-key-file"` TFDownloadURL string `mapstructure:"tf-download-url"` TFEHostname string `mapstructure:"tfe-hostname"` + TFELocalExecutionMode bool `mapstructure:"tfe-local-execution-mode"` TFEToken string `mapstructure:"tfe-token"` VCSStatusName string `mapstructure:"vcs-status-name"` DefaultTFVersion string `mapstructure:"default-tf-version"`