Joey Yi Zhao
Joey Yi Zhao

Reputation: 42418

How can I connect to private endpoint from local?

I created a private endpoint in AWS API Gateway to make it private. Only resources in the private vpc can access to this endpoint. This is my design and it works very well. The problem is that it makes me a bit hard to connect it from my local computer.

As a workaround, I can launch a EC2 instance which in the same VPC and I can connect to this EC2 to access the endpoint. But it is not easy to do. I'd like to run postman from my local to connect to the API endpoint. I am looking for a better way to allow me to access it from my local.

Can anyone help me on that?

Upvotes: 1

Views: 2497

Answers (1)

Marcin
Marcin

Reputation: 238071

There are few ways. One one would be VPN, but I personally use proxy capability of postman. What I do has five stages.

1. Bastion host - Amazon Linux 2

with ssh port open in a public subnet.

2. ssh dynamic tunnel

ssh -D 1080  -C -q -N -oStrictHostKeyChecking=no -l ec2-user  <public-ip-of-your-bastion> -v

The command will create SOCKS5 proxy from your local workstation to the bastion on port 1080.

3. HTTP -> SOCKS5 conversion

Since postman does not support SOCK5, a conversion is needed. I use http-proxy-to-socks:

hpts -s 127.0.0.1:1080 -p 8080

which will create HTTP proxy on port 8080 forwarded to SOCKS5 proxy on port 1080.

4. Setup HTTP proxy on postman

enter image description here

5. Query private API from postman

Query the private API from your local workstation using its https endpoint, just like if it was a public API.

Upvotes: 3

Related Questions