The next thing we will do is to set up an AWS API Gateway Proxy in front of the Lambda function we described in an earlier article.

We need to select the API Gateway service and create an API to interact with Campaigns like in the following screenshot:

Next we need to create a Proxy resource. This means that any request will simply be redirected to the Lambda function. To do this, we can select the “Create Resource” function from the “Actions button”, check the “Configure as Proxy” checkbox and then select the “Create Resource” button.

Then in the next screen we select the Lambda function we created in an earlier article

And finally we click “Save”. At this point we can test the function by clicking on the ANY Resource and click Test. Select the GET method and then click “Test”. This will return you the content of the JSON file that we uploaded as static content as in the following screenshot.

Again, as this is a static file, don’t worry too much about the content. This will become dynamic once we start storing campaigns in the database.

The last thing you want to do is to enable CORS (Cross Origin Resource Sharing). On the CampaignsAPI, select the /{proxy+} resource, then Actions and then “Enable CORS”. Check the DEFAULT 4XX and DEFAULT 5XX checkboxes to get the right headers also in case of errors.

Once you complete the operation, you should get an output like the following: