I know that one way is to use a load balancer in a public subnet, but for a development server we wouldn't need a load balancer. Is there an alternative option that would allow an application in a private subnet to be reachable from the internet?
If not, then would the best option be to just leave the development server in a public subnet? The database instances would still be in a private subnet.
An Amazon EC2 instance in a private subnet will never be directly reachable from the Internet, even if it has a public IP address. This is because a private subnet does not have a Route Table entry that connects the subnet to an Internet Gateway. This is intentional and desired.
So, your options are:
Port Forwarding is a common technique to provide private connectivity to a resource that is not directly accessible. For example:
Public-Instance
in the public subnetPrivate-Instance
in the private subnetPublic-Instance
with port forwarding, which then establishes a connection to Private-Instance
Private-Instance
A sample connection string would be:
ssh -i pemfile ec2-user@public-instance -L 8000:private-instance:80
Any request sent to your local computer's port 8000 would be forwarded to Public-Instance
, which would then forward the request to private-instance:80
. This will continue as long as the SSH session is in place.