Using a custom VPC to create an EC2 instance

0

Hi,

As the title says, I'm trying to create an EC2 instance using a custom VPC, so that I can connect to an EFS that has mountpoints in the same VPC. I've created EC2 instances using the default VPC before, and I followed the same steps but just changing the VPC on setup, however once the instance is created, I'm unable to connect to it using EC2 Instance Connect, and it raises the following error:

Failed to connect to your instance EC2 Instance Connect is unable to connect to your instance. Ensure your instance network settings are configured correctly for EC2 Instance Connect.

Any help would be greatly appreciated.

hczhang
asked 10 months ago353 views
2 Answers
2

Which OS are you running, and does it have Instance Connect pre-installed? https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html

There are differences with the default VPC (that you've worked with before) and a custom VPC that you're using now. The default VPC is already setup with an internet gateway, and subnets whose routing tables already have a route to the internet gateway. The custom VPC doesn't have any of this, and you're going to have to setup these components and get them all working together.

As you've already provisioned an EC2 instance into the custom VPC it means at least one subnet will have been created. The next thing to look at would be making sure it is reachable, the details are in here https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html (actually many of the items in the pane on the left hand side may come in useful at some point).

profile picture
EXPERT
Steve_M
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago
  • I got it. My custom VPC had two subnets, one private and one public. I used the private one to mount it to my lambda function, so I assumed the private subnet would also work for the EC2 instance, but it didn't. However, when I changed the EC2 instance subnet to the public one, I was able to connect.

2

There's not enough information to troubleshoot this issue - for example, how is the VPC configured? Subnets, route tables, internet gateway and so on. The first place I'd go to is the EC2 Instance Connect documentation which lists the prerequisites for getting the service to work.

profile pictureAWS
EXPERT
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions