user7496277
user7496277

Reputation:

How can I use an EC2 ip address in API Gateway?

I have a Flask API that I am serving with Gunicorn on an EC2 instance, I am trying to use AWS API Gateway to connect my endpoints but I get an error when trying to use the ip of my EC2 instance for the endpoint url.

My endpoint looks like this ec2-x-x-xxx-xx.eu-west-.compute.amazonaws.com:8080/scraper/run

enter image description here

Upvotes: 0

Views: 1464

Answers (1)

Steve HOUEL
Steve HOUEL

Reputation: 197

You should consider 2 options:

  1. If your EC2 is publicly available you should check the HTTP Proxy integration part to delegate the integration request and response configuration to your Flask API oterwise you will have to configure it on your API Gateway.

If your EC2 is publicly available you should have an inbound rule 0.0.0.0/0 on it. If not I think your should consider option 2.

  1. In that case, your EC2 is not publicly available this means API Gateway will not communicate with your instance through internet but through a Private Link.

Look at this blog post to configure your VPC Endpoint and then restrict and secure your communication : https://aws.amazon.com/fr/blogs/compute/introducing-amazon-api-gateway-private-endpoints/

Upvotes: 1

Related Questions