Amazon API Gateway HTTP Proxy Integration Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 36: Line 36:
==Create Resources==
==Create Resources==


The root resource is created with the API. Additional resources can be created by going to API -> <''API name''> -> Resources -> "/" -> Actions -> Create Resource.
Additional resources can be created by going to API -> <''API name''> -> Resources -> "/" -> Actions -> Create Resource.


For the simplest possible proxy integration, the only resource created under root is a [[Amazon_API_Gateway_Concepts#Proxy_Resource|proxy resource]], meaning that it forwards everything that comes to the integration endpoint.
For the simplest possible proxy integration, the only resource created under root is a [[Amazon_API_Gateway_Concepts#Proxy_Resource|proxy resource]], meaning that it forwards everything that comes to the integration endpoint.


Resource name: "proxy"


Resource Path: /{proxy+}
Select "/" -> Actions -> Create Resource.
 
Configure as "proxy resource". This is just a convenience control, will fill out the fields with appropriate values,
 
Resource name: proxy
 
Resource path: {proxy+}


Enable API Gateway [[Amazon_API_Gateway_Concepts#CORS|CORS]].
Enable API Gateway [[Amazon_API_Gateway_Concepts#CORS|CORS]].


{proxy+} ANY Setup:
Create Resource.
 
The resource thus created comes with an "ANY" method.
 
Select it and configure it as follows:
 
Integration type: VPC Link.
 
Use Proxy Integration: Check. <font color=darkgray>Why do we need to check that, while we're selecting "VPC Link" above anyway?</font>
 
VPC Link: Use Stage Variables


<font color=darkgray>
Stage Variable: <tt>${stageVariables.vpcLinkId}</tt>


Integration type:  HTTP Proxy
We can select the VPC Link directly in the drop-down box, but using a stage variable gives us more flexibility, as we can simultaneously deploy in two different stages and use two different VPC Links.


Endpoint URL: http://themyscira.playground/{proxy}
Endpoint URL: http://playground-nlb-95d74901c7b728b1.elb.us-west-2.amazonaws.com/{proxy} <font color=darkgray>More clarifications here.</font>


Content Handling: Passthrough
Content Handling: Passthrough

Revision as of 01:32, 12 February 2019

Internal

Overview

Playground

Amazon API Gateway - HTTP Proxy Integration Example

Procedure

Create the API

API Gateway Console -> APIs -> Create API

Protocol

REST

Create new API

New API

Settings

API Name: themyscira

Description:

Endpoint Type: Regional.

Create API: the API, and its root resource will be created.

Create Resources

Additional resources can be created by going to API -> <API name> -> Resources -> "/" -> Actions -> Create Resource.

For the simplest possible proxy integration, the only resource created under root is a proxy resource, meaning that it forwards everything that comes to the integration endpoint.


Select "/" -> Actions -> Create Resource.

Configure as "proxy resource". This is just a convenience control, will fill out the fields with appropriate values,

Resource name: proxy

Resource path: {proxy+}

Enable API Gateway CORS.

Create Resource.

The resource thus created comes with an "ANY" method.

Select it and configure it as follows:

Integration type: VPC Link.

Use Proxy Integration: Check. Why do we need to check that, while we're selecting "VPC Link" above anyway?

VPC Link: Use Stage Variables

Stage Variable: ${stageVariables.vpcLinkId}

We can select the VPC Link directly in the drop-down box, but using a stage variable gives us more flexibility, as we can simultaneously deploy in two different stages and use two different VPC Links.

Endpoint URL: http://playground-nlb-95d74901c7b728b1.elb.us-west-2.amazonaws.com/{proxy} More clarifications here.

Content Handling: Passthrough

Use Default Timeout.