Problem
When using the Terraform AWS provider versions 5.65.0 or 5.66.0, you may encounter a connection error during terraform plan or terraform apply operations.
An example configuration that may trigger this issue is shown below.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.65.0"
}
}
}
resource "random_string" "test" {
length = 16
lower = true
special = false
}
resource "aws_secretsmanager_secret" "test" {
name = random_string.test.result
}The operation fails with the following error message.
exceeded maximum number of attempts, 25, https response error StatusCode: 0, RequestID: , request send failed, read: connection reset by peer.
Cause
The Terraform AWS provider versions 5.65.0 and 5.66.0 were built using GoLang 1.23.0. This upgrade introduced a change that causes connectivity issues, resulting in the connection reset by peer error.
The AWS SDK version string change reflects this GoLang update.
- aws-sdk-go-v2/1.30.4 os/linux lang/go#1.22.6 md/GOOS#linux md/GOARCH#amd64 api/acm#1.28.5 + aws-sdk-go-v2/1.30.4 os/linux lang/go#1.23.0 md/GOOS#linux md/GOARCH#amd64 api/acm#1.28.6
Solutions
Solution 1: Upgrade the AWS Provider
To resolve this issue, upgrade the Terraform AWS provider to version 5.67.0 or newer. This version reverts the GoLang dependency back to 1.22.0, which resolves the connectivity problem.
Update the version constraint in your Terraform configuration.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.67.0"
}
}
}After updating the configuration, run terraform init -upgrade to download the new provider version.
Additional Information
For more details on the fix, refer to the pull request that reverted the GoLang version: GitHub PR #39256.