Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Log streaming broken with TFE local execution mode #2364

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
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"`
VCSStatusName string `mapstructure:"vcs-status-name"`
DefaultTFVersion string `mapstructure:"default-tf-version"`
Expand Down