Search code examples
javascriptnode.jsamazon-web-servicesapivelo

how do I run an http request from a dynamic IP webpage, thru an AWS static IP, since the endpoint API needs to be from a whitelisted IP?


I am working on a project where I have a Wix site (the important thing is that thru Wix I am forced to use a dynamic IP).

The API that I want to send requests to, only accepts whitelisted IPs. I can easily add a whitelisted IP to the list. In fact, I've already got an AWS EC2 server running node/fetch, that has an elastic IP, which is whitelisted, getting good responses.

The problem is, and it be a noob question, How do i connect my wix back-end to AWS thru my elastic IP to an external API, and get info back.

back-end --> AWS --> API endpoint API endpoint --> AWS --> back-end

I've done my due diligence, and have even asked a similar question myself and not received answers. I need a HTTP guru. thanks in advance

I've not worked on the Wix to AWS part yet, but as for the AWS to API part I have created an EC2 server, connected thru ssh, installed node, installed fetch, used filzilla to drop a js file i wrote on my local machine. I hooked up an elastic IP that i whitelisted for the API endpoint to the EC2 server/instance. I ran the js file and i am able to get auth, add data and pull data back.

I don;t know how to integrate all of the AWS services however, I am new to AWS and while I am amazed at what I can do sometimes, other times, i get overwhelmed with all the connections and products.

I've successfully created an SQS queue, and pushed to lambda functions, i get 200 responses from the API, but they are not the typical "not whitelisted IP" responses. they refer to 127.0.0.1:443. i researched this port and seen its usually used as a secure port.

i've made requests with API gateway, i get the "not whitelisted IP" response, which is expected since the IPs change dynamically on API gateway.

My vision is that I'll need to incorporate -SQS -Lambda -API Gateway -VPC -and probably abandon my EC2

///its a basic node-fetch request


Solution

  • the solution I discovered is to use Wix Corvid to send to an SQS query in AWS. then write code and host it on an EC2 instance, with a whitelisted IP. the node script on the EC2 calls the SQS queue and does a fetch with the proper message forwarded on. since you can assign a static IP to EC2s using Elastic IP in AWS, this solves the problem. the EC2 and SQS (AWS Services) act as a proxy which passes all info to the endpoint.