Open praveenprem opened 2 years ago
I got a colleague to run this exact same thing on x86 (Intel i5) and it worked the first time.
Hey @praveenprem π Thank you for taking the time to raise this, and for the additional follow up that your colleague didn't run into the same issues. In this case, I think the debug logs would be quite helpful. As far as your question around securely sharing those logs, the best bet would be to use our public GPG key to encrypt them. The key may be found on keybase at: https://keybase.io/hashicorp
Hey @justinretzolk, Thanks for the reply.
Here are the trace logs for the issue I had yesterday. terraform.log.gpg.zip
I'm having much better luck today but still, get errors from time to time.
Hi @justinretzolk, thought this might interest you. We've discovered a weird situation where the same colleague also got similar errors today on an x86 machine and the common factor was that we both get these errors on BT ISP (UK). Whereas last time my colleague tried it on a different ISP (Three) where it worked for him.
He got the same connection reset by peer
error on the AWS Provider and I believe that this is caused by the AWS side, although it's not isolated to a single BT connection as I get this on our office network and my home network where they both provided by BT.
is there a way to do retries? it happens to me and screwing with automation
do we know the reason for it ? I am facing same issue at some terraform init
runs(not in every case)
@vineetsharma883 My guess would be that AWS has changed their API rate limits which cause this issue. So there's nothing we can do other than run Terraform within an EC2 instance that might bypass the public API rate limits.
@matanr-orca This could be something you can explore with automation.
Same trouble today with a terraform init -reconfigure -backend=true
: I 100% reliably Error refreshing state: Failed to read remote state: read tcp 192.168.1.154:59696->52.216.99.53:443: read: connection reset by peer
Running with TF_LOG=debug
, I see that:
sts.amazonaws.com
commands (sts/GetCallerIdentity) succeed!s3.amazonaws.com
commands (s3/ListObjects, s3/ListObjects) succeed!2023-05-15T05:35:16.771-0400 [DEBUG] [aws-sdk-go]
line, with no details of what aws-sdk-go was trying to do π)Extra info confirming above-reported inconsistency:
A nit, finally: @vineetsharma883 can you update this issue title to end with when Terraform apply / init
? (Adding / init
)
Fixed my case! Mine was quite dumb, and although I can't confirm it's the reason for all the upvoters of https://github.com/hashicorp/terraform-provider-aws/issues/23614 and https://github.com/hashicorp/terraform-provider-aws/issues/14163 , given the number of upvotes they have, I'm pretty sure at least a couple had the same problem than I had. Hold your beer, it's pretty dumb. Are you ready?
My wifi was dog slow (<1kbps), causing reproducible failure/timeout to download $work's large (2MB) terraform.tfstate
hosted on S3 :facepalm: . Most small REST calls to AWS worked (which was confusing!), but downloading this large file was too slow and broke my tf command. After fixing my wifi, no more errors.
β @justinretzolk again, zarroo guarantee/clue that it's the single root for this issue. That being said, given the critical-ness of being able to download the tfstate, what about adding a lil' "quality of life" / "helping users not shooting themselves in the foot" feature that:
tfstate
cannot be downloaded reasonably fast ...tfstate
download in a try/catch (or golang equivalent, pardon my non-golangness), leaving the current net/http "connection reset by peer" behavior as-is ... but instead of aborting with a cryptic connection reset by peer
error (when doing what? calling what URL), printing some kind of user-helpful error like Failed to download state file <uri_to_tfstate>, aborting. Maybe you, or your ISP, or your hosting provider, has network quality/speed trouble.
Thanks for terraform and tf-provider-aws π.
Hey @ronjouch π Thank you for following up! What an interesting situation! π For that sort of a request, you'd want to file an issue in the Terraform Core repository, since downloading the state is part of Core rather than the AWS provider (and given the situation, I'd imagine this could impact other backends as well).
In my case, this is due to rate limiting at some level (not sure if AWS, internet provider or other).
My solution has been to limit the Terraform operations parallelism; 10 is the default, and 8 (-parallelism=8
) worked for me.
Hope it helps somebody π
In my case, this is due to rate limiting at some level (not sure if AWS, internet provider or other).
My solution has been to limit the Terraform operations parallelism; 10 is the default, and 8 (
-parallelism=8
) worked for me.Hope it helps somebody π
@64kramsystem thank you for the solution
In my case, this is due to rate limiting at some level (not sure if AWS, internet provider or other). My solution has been to limit the Terraform operations parallelism; 10 is the default, and 8 (
-parallelism=8
) worked for me. Hope it helps somebody π@64kramsystem thank you for the solution
Some time after, I've upgraded the AWS provider, and didn't need to limit the parallelism anymore :smile:
I am using aws provider 4.67 and yesterday only i start getting this connection reset by peer and tfstate is not able to refresh properly. Any solution for this? Is it an issue from aws side ?
I am using aws provider 4.67 and yesterday only i start getting this connection reset by peer and tfstate is not able to refresh properly. Any solution for this? Is it an issue from aws side ?
@mayank0202 I suspect that there are too many resources in the TF config, I've been working on smaller TF modules and haven't seen this issue lately. It's only those with 100+ resources getting this issue.
I am using aws provider 4.67 and yesterday only i start getting this connection reset by peer and tfstate is not able to refresh properly. Any solution for this? Is it an issue from aws side ?
@mayank0202 I suspect that there are too many resources in the TF config, I've been working on smaller TF modules and haven't seen this issue lately. It's only those with 100+ resources getting this issue.
@praveenprem I faced this issue where my module has to deploy only 9-10 resources and my team also faced the same issue so thats why i thought if there maybe an issue from aws side
@mayank0202 Does it happen on an ISP that only you're calling the AWS API as well? If you're getting the error at work where other people are also running Terraform, AWS is probably throttling the work networks' public IP.
If you've access to a VPN provider I'd try that at work to disassociate from the work public IP to test the theory. That worked for me when I had issues with larger scripts I had problems with.
We get the following error while running terraform apply in a github action during terraform apply
Error saving state: failed to upload state: RequestError: send request failed
caused by: Put βhttps://s3-state-file-locationβ:
tcp read: connection reset by peer
I don't think its related to ISP in my case.
Our Configuration: Terraform - 1.5 AWS provider version - 5.31
Any solution for this?
@jayanthankj Unfortunately, we don't know exactly why it's happening. Rate limit is just a theory that's most likely to happen. The only solution to this is to run Terraform from an EC2 instance as that seems to not have this problem.
You can try running a private worker in an EC2 and testing it.
I have a very similar behaviour in Azure (Azure VM as a build agent, azurerm is a provider). I mean, it's probably not a provider level, but terraform engine level issue.
Community Note
Terraform CLI and Terraform AWS Provider Version
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
I'm happy to provide the trace logs, do you have a method of securing the data? Such as the use of GPG encryption.
Panic Output
There's no panic output.
Expected Behavior
Terraform should prompt for the confirmation of
terraform apply
.terraform plan
however does not experience this issue.Actual Behavior
RequestError: send request failed
occurs during state refresh.Other instances
Steps to Reproduce
terraform init
terraform apply
Important Factoids
References
0000