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 remote execution on Terraform Cloud after v1.1.0 #2793

Merged
merged 5 commits into from
Dec 15, 2022

Conversation

lilincmu
Copy link
Contributor

@lilincmu lilincmu commented Dec 13, 2022

what

  1. Update the error message returned by Terraform Cloud on remote execution with -out argument.
  2. Add -no-color argument for plan/apply remote execution.

why

Similar to #1687, the error message returned by Terraform CLI for remote execution changed yet again after v1.1.0. We rely on the error message to determine whether we should run another plan/apply commands in consideration of the execution to be remote.

references

There seems to be no related issue created yet. But this potentially solves the problem mentioned in #1628 (comment)

@lilincmu lilincmu changed the title Tfc remote execution fix Fix remote execution on Terraform Cloud after v1.1.0 Dec 13, 2022
}

// remotePlan runs a terraform plan command compatible with TFE remote
// operations.
func (p *PlanStepRunner) remotePlan(ctx command.ProjectContext, extraArgs []string, path string, tfVersion *version.Version, planFile string, envs map[string]string) (string, error) {
argList := [][]string{
{"plan", "-input=false", "-refresh"},
{"plan", "-input=false", "-refresh", "-no-color"},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the change, the output in the comment contains color code and doesn't look very nice.
Screen Shot 2022-12-13 at 2 24 11 PM

Also, I was debating whether to check tfVersion before adding the extra -no-color argument, and felt it might be fine to ignore it for better readability in the main code and the test cases. -no-color seems to have been introduced in Terraform since very early on (at least before v0.11).

@lilincmu
Copy link
Contributor Author

lilincmu commented Dec 13, 2022

This fix is only meant to solve part of the issues for remote execution mentioned in the PR description.

There is another issue #2794 on the apply step for remote execution which I feel should be addressed separately.

@lilincmu lilincmu marked this pull request as ready for review December 13, 2022 23:42
@lilincmu lilincmu requested a review from a team as a code owner December 13, 2022 23:42
@lilincmu lilincmu merged commit 812db63 into runatlantis:main Dec 15, 2022
krrrr38 pushed a commit to krrrr38/atlantis that referenced this pull request Dec 16, 2022
* Fix remote execution on Terraform Cloud after v1.1.0

* Do not check terraform version for -no-color

* Move string comparison for newer version earlier

* Update remote apply test
@nitrocode nitrocode added this to the 0.22.0 milestone Dec 23, 2022
@sudermanjr
Copy link

sudermanjr commented Dec 28, 2022

I am using the pre-release from 12/26, and I still seem to have the issue with remote execution in Terraform versions greater that 1.1 (I have tried several)

│ Error: Saving a generated plan is currently not supported
│ 
│ The "remote" backend does not support saving the generated execution plan
│ locally at this time.
╵

Should I file another issue, or is there something I am missing in my configuration? For now I am going to override the workflow

@nitrocode
Copy link
Member

Yes please file another issue, link this pr to it, and please provide as much information as possible.

cypres referenced this pull request Jan 23, 2024
* chore(atlantis): fix linter errors

* fix superfluous-else

* revert gitlab check

* ignore stub funcs on azuredevops_client

* remove fetch-depth

* remove fail_on_error

* fix plan_step_runner_test.go

* more lint fixes

---------

Co-authored-by: Dylan Page <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants