-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Different Terraform versions #4935
Comments
Hello @hakuno! I'm here to help you with any bugs, questions, or contributions you have. Let's tackle this Terraform version issue together while we wait for a human maintainer. I found a similar open issue that might be relevant to your problem: Using previous versions of Terraform no longer works. This issue was last updated on June 27, 2024, and currently has no comments or solution [1]. To resolve the error "Failed to read plan from plan file" when using different Terraform versions (1.9.5 and 1.9.6) in Atlantis v0.29.0, you need to ensure that the plan file is compatible with the Terraform version being used. The error typically occurs because the plan file generated by one version of Terraform is not readable by another version. Here are some steps to ensure compatibility:
Here is a snippet from the func (p *planStepRunner) Run(ctx command.ProjectContext, extraArgs []string, path string, envs map[string]string) (string, error) {
tfVersion := p.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
}
planFile := filepath.Join(path, GetPlanFilename(ctx.Workspace, ctx.ProjectName))
planCmd := p.buildPlanCmd(ctx, extraArgs, path, tfVersion, planFile)
output, err := p.TerraformExecutor.RunCommandWithVersion(ctx, filepath.Clean(path), planCmd, envs, tfVersion, ctx.Workspace)
if p.isRemoteOpsErr(output, err) {
ctx.Log.Debug("detected that this project is using TFE remote ops")
return p.remotePlan(ctx, extraArgs, path, tfVersion, planFile, envs)
}
if err != nil {
return output, err
}
return p.fmtPlanOutput(output, tfVersion), nil
} Ensure that the Additionally, you can enforce the use of a specific Terraform version across all steps by setting the Example using --default-tf-version=v1.3.7 Example using version: 3
projects:
- dir: .
terraform_version: v1.1.5 Alternatively, you can use the Example using terraform {
required_version = "= 1.2.9"
} Atlantis will automatically download the latest version that fulfills the specified constraint [3][4]. |
So I see |
Community Note
Overview of the Issue
From built-in step
Results in Terraform 1.9.6
From custom step
Results in Terraform 1.9.5
So if I use both
Reproduction Steps
Logs
Environment details
Atlantis v0.29.0
Additional Context
The text was updated successfully, but these errors were encountered: