Skip to content

Commit

Permalink
fix: Log streaming broken with TFE local execution mode (#2364)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperbiering authored Jul 12, 2022
1 parent b650303 commit abb9e41
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const (
VarFileAllowlistFlag = "var-file-allowlist"
VCSStatusName = "vcs-status-name"
TFEHostnameFlag = "tfe-hostname"
TFELocalExecutionModeFlag = "tfe-local-execution-mode"
TFETokenFlag = "tfe-token"
WriteGitCredsFlag = "write-git-creds"
WebBasicAuthFlag = "web-basic-auth"
Expand Down Expand Up @@ -422,6 +423,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,
Expand Down
1 change: 1 addition & 0 deletions cmd/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions runatlantis.io/docs/server-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions runatlantis.io/docs/terraform-cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions server/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
VarFileAllowlist string `mapstructure:"var-file-allowlist"`
VCSStatusName string `mapstructure:"vcs-status-name"`
Expand Down

0 comments on commit abb9e41

Please sign in to comment.