1

I have instance connect working fine from the CLI on my local machine as I have my ip added to the security group for the ec2 instance for inbound ssh access.

However, the browser-based version in the EC2 Console seems to need me to add all internet for inbound access to make it work! I am sure it just needs to be certain AWS IP ranges, but there is no documentation anywhere that I can find to tell me what they are. Also, I have no idea how much of a pain this might be to maintain if those ranges are dynamic or something.

Can anyone help?

Thanks

1 Answers1

2

From Set Up EC2 Instance Connect - Amazon Elastic Compute Cloud:

(Browser-based client) We recommend that your instance allows inbound SSH traffic from the recommended IP block published for the service. Use the EC2_INSTANCE_CONNECT filter for the service parameter to get the IP address ranges in the EC2 Instance Connect subset.

This is because the web browser client connects via HTTPS to the EC2 Instance Connect "service" in AWS. This service then makes the actual SSH connection to the instance.

A sample of the IP address file is:

{
"ip_prefix": "18.206.107.24/29",
"region": "us-east-1",
"service": "EC2_INSTANCE_CONNECT"
},
{
"ip_prefix": "18.228.70.32/29",
"region": "sa-east-1",
"service": "EC2_INSTANCE_CONNECT"
},
{
"ip_prefix": "18.237.140.160/29",
"region": "us-west-2",
"service": "EC2_INSTANCE_CONNECT"
},

Thus, these are the ranges you should add to the Security Group. Just use the range(s) for the region where you are invoking EC2 Instance Connect.

John Rotenstein
  • 165,783
  • 13
  • 223
  • 298
  • Hi John, I am guessing these ranges don't change that often so it is ok to hardcode them in the security group? – danrockcoll Feb 24 '20 at 15:03
  • That choice is yours. They will stay the same until they don't. If the change will be easily detected and will not impact many people, then you could choose to hardcode them. The alternative is to write a small program that will retrieve the ranges and update the security group, then schedule it to run daily. Your choice! – John Rotenstein Feb 24 '20 at 20:33
  • yeah i think its not worth the effort to try and keep it updated automatically, it will be easy to detect when it has changed as someone will inevitably scream! many thanks for your help on this :) – danrockcoll Feb 25 '20 at 11:54