-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Provisioning with SSH on AWS times out #17140
Comments
More info: I ran terraform again on the same configuration, it was supposed to replace 3 instances. The provisioning worked on 2 of them and not on another. It's possible there's something wrong on my end, perhaps network related. However, I can't explain being able to connect directly but not through terraform. |
Hi @vdemario, Sorry you're having an issue here. Is that the extent of the output that you see which is being repeated? Can you get the trace log output from terraform when this happens? The only situation I can think of is that terraform got the wrong (or empty) information from the provider, but I"m not sure that could happen yet. |
Hi @jbardin, I do have a trace log at https://drive.google.com/file/d/1OxOND5AOvJnZJG-K2Mouqf38m5PY7piu/view?usp=sharing. I edited a little bit of it in the beginning because I was concerned about credentials then gave up on editing and encrypted with the HashiCorp security public key. It was generated at the time of my last comment, when provisioning worked for 2 instances and failed on 1. |
Thanks for the logs!, Unfortunately they weren't very enlightening. What I didn't notice at first glance though is that the |
@vdemario I experienced the same problem. In my case, the issue was that the security group that was being applied to the instance did not allow SSH connections. Once allowing it from the SG, I could achieve it. |
That's not the case @ricardoserradas. I could connect directly outside terraform and these are very old security groups that only exist specifically for SSH. |
I had the same issue today, so let me add more context to you guys how I solved it: I changed from spot instances to a normal one (using Let me know if there is something that I can provide to you guys, like logs or something to help in this case. |
BTW, @marcosinger works with me so he's talking about the same terraform configuration as me. @jbardin this reminds me: the empty Host is probably because of the spot instance request. Tags get applied to the spot request instead of the instance so the name is lost when we use spot instances. See #3263. |
I have the same problem. I had a working configuration with regular instances and changed to spot instances. Now Terraform times out trying to connect via SSH. While logging in with SSH from another terminal works fine. Running with TF_LOG=DEBUG shows the following:
|
I found the solution now. For spot instances you need to add "wait_for_fulfillment = true" to make SSH remote exec provisioning work. |
@ofrzeta I did the same here and it works. I also added |
Looks like using the file provisioner can cause Terraforms "aws_instance" creation to time out. Interesting this only happens on some of our AWS environments. Removing the file provisioner block and the EC2 instance is created in a few seconds, and accessible using ssh. |
The original issue here was caused by the Since there is no further development of 0.11 happening, we can close this out . |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
We've been provisioning machines with SSH on terraform for several months now. Today, for the first time, SSH timed out. I thought, at first, there was something wrong with the network or security group configuration on Amazon, perhaps our IP changed even though it was supposed to be fixed.
None of that happened and I can successfully connect via SSH to the instances created by Terraform. In fact, not only I can connect but if I run the inline commands manually that way everything works as expected.
Terraform Version
I started experiencing this problem with v0.11.1 and upgraded hoping it would fix it. The first attempt at
terraform apply
with v0.11.2 succeeded. Later I changed the instance_count and the problem happened again.Terraform Configuration Files
Expected Behavior
aws_spot_instance_request.abcd_worker (remote-exec): Login Succeeded
and then the inline commands.Actual Behavior
SSH connection never happens and the following log messages loop until the apply command runs for 5 minutes and times out.
Steps to Reproduce
terraform apply
with the remote-exec/ssh provisioner is all we're doing.References
I suspected my issue was related to #17117 since it mentions AWS security groups as well but it might not have any connection. I started having these problems on v0.11.1 and the security groups on my terraform configuration are being applied correctly.
The text was updated successfully, but these errors were encountered: