diff --git a/server/core/terraform/terraform_client.go b/server/core/terraform/terraform_client.go index 7ca6fc7277..89c02c8634 100644 --- a/server/core/terraform/terraform_client.go +++ b/server/core/terraform/terraform_client.go @@ -338,6 +338,11 @@ func (c *DefaultClient) DetectVersion(log logging.SimpleLogging, projectDirector } constraint, _ := version.NewConstraint(requiredVersionSetting) + // Since terraform version 1.8.2, terraform is not a single file download anymore and + // Atlantis fails to download version 1.8.2 and higher. So, as a short-term fix, + // we need to block any version higher than 1.8.1 until proper solution is implemented. + // More details on the issue here - https://github.com/runatlantis/atlantis/issues/4471 + highestSupportedConstraint, _ := version.NewConstraint("<= 1.8.1") versions := make([]*version.Version, len(tfVersions)) for i, tfvals := range tfVersions { @@ -355,7 +360,7 @@ func (c *DefaultClient) DetectVersion(log logging.SimpleLogging, projectDirector sort.Sort(sort.Reverse(version.Collection(versions))) for _, element := range versions { - if constraint.Check(element) { // Validate a version against a constraint + if constraint.Check(element) && highestSupportedConstraint.Check(element) { // Validate a version against a constraint tfversionStr := element.String() if lib.ValidVersionFormat(tfversionStr) { //check if version format is correct tfversion, _ := version.NewVersion(tfversionStr) diff --git a/server/core/terraform/terraform_client_test.go b/server/core/terraform/terraform_client_test.go index 29fccb4579..cfa0f60fb3 100644 --- a/server/core/terraform/terraform_client_test.go +++ b/server/core/terraform/terraform_client_test.go @@ -393,6 +393,12 @@ terraform { // cannot use ~> 1.3 or ~> 1.0 since that is a moving target since it will always // resolve to the latest terraform 1.x "~> 1.3.0": "1.3.10", + // Since terraform version 1.8.2, terraform is not a single file download anymore and + // Atlantis fails to download version 1.8.2 and higher. So, as a short-term fix, + // we need to block any version higher than 1.8.1 until proper solution is implemented. + // More details on the issue here - https://github.com/runatlantis/atlantis/issues/4471 + ">= 1.3.0": "1.8.1", + ">= 1.8.2": "", } type testCase struct {