Issue
I have a jenkins server in company network. Need to spin an EC2 instance using jenkins ec2 plugins. I was under impression that after giving access, secret keys and AMI Id, opening security group for ssh port 22 (its a linux image). I would be able to connect ec2 instance as slave. But its throwing below error.
Connecting to 172.30.0.204 on port 22, with timeout 10000.
Waiting for SSH to come up. Sleeping 5.
Connecting to 172.30.0.204 on port 22, with timeout 10000.
Waiting for SSH to come up. Sleeping 5.
Connecting to 172.30.0.204 on port 22, with timeout 10000.
Waiting for SSH to come up. Sleeping 5.
Connecting to 172.30.0.204 on port 22, with timeout 10000.
Waiting for SSH to come up. Sleeping 5.
Connecting to 172.30.0.204 on port 22, with timeout 10000
.
I am able to connect ec2 instance using public ip from my local machine. All i can see is that jenkins trying to access using private ip. I have given a subnet id since its in vpc. Any settings in jenkins or VPC which need to be changed?
Regards, Ashish
Solution
OK, I think I figured it out.
For the plugin to work correctly, you need to have a default VPC. I deleted all my default VPC's, because I mistakenly thought in the beginning that it would cost me to keep them running.
The consequence of a default VPC seems to be that a public DNS is attached to the instances launched in that default VPC. I might be mistaken about the fact that only a default VPC does that (perhaps there is a setting I yet have to discover for a VPC to automatically assign a public DNS), but in any case, a public DNS was only added to my server in the setup with the default VPC. And it seems that the fallback for the plugin is to try and connect to the private IP. When you look at the settings of the instance, you only see input fields for the public dns and the private ip -- not the public ip.
Once I got that out of the way, everything spun up correctly.
So, how do you go about getting a default VPC again, after you have deleted yours? Well, generally, there are 2 options:
- You register for a new account. This is the easiest, but of course, you get a new account.
- You can have a look at https://aws.amazon.com/premiumsupport/knowledge-center/deleted-default-vpc/ , to see the procedure for AWS to give you back a default VPC.
I basically went for the first option, for now.
Hope this helps!
Answered By - gjoris
Answer Checked By - David Goodson (JavaFixing Volunteer)