Search code examples
amazon-web-servicesamazon-ec2aws-security-group

Expose port to EC2 instance of another machine


I want to expose port of a EC2 machine(us-west-2b) to access from another machine(us-west-2a). For that, I have created a security group with CIDR range.

check the below image : enter image description here

But it is not opening the port. What is the right way of achieving this without making port public

I have created a security group and added that security group to two machines. For each machine, i have exposed 9001 port to the newly created security group. Now i tried accessing port of one machine from another machine But it is not working.

enter image description here


Solution

  • Use different security groups, one per EC2 instance.

    then edit that one you want to open the PORT and add as a source the other security group.

    Check this example ... I am opening port 3306 only for SG: sg-xxxx

    enter image description here

    then use the private IP address and NOT the public IP.