Amazon API Gateway HTTP Proxy Integration Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(13 intermediate revisions by the same user not shown)
Line 31: Line 31:


Endpoint Type: [[Amazon_API_Gateway_Concepts#Regional_API|Regional]].
Endpoint Type: [[Amazon_API_Gateway_Concepts#Regional_API|Regional]].
Create API: the API, and its root resource will be created.


==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.
 
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.
 
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]].
 
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
 
Stage Variable: <tt>${stageVariables.vpcLinkId}</tt>
 
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:10001/{proxy} <font color=darkgray>More clarifications here. Why do I need to specify an endpoint URL, when the VPC Link should already be wired into the network load balancer.</font>
 
Use Default Timeout.
 
===Test===
 
{proxy+} -> ANY -> Test:
 
Method: GET
 
Path: amazons
 
Stage Variables:
 
vpcLinkId: xemf89
 
Test.
 
Should get 200.
 
==Deploy API==
 
API -> themyscira -> / -> Actions -> Deploy API
 
Deployment Stage: New Stage
 
Stage name: test
 
===Stage Settings===
 
====Stage Variables====
 
Add Stage Variables.
 
Name: vpcLinkId
 
Value: xemf89
 
Make sure to click the check sign, otherwise they won't be saved and the invocations will get "Internal server error"
 
Back to Settings -> Save Changes.

Latest revision as of 01:54, 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:10001/{proxy} More clarifications here. Why do I need to specify an endpoint URL, when the VPC Link should already be wired into the network load balancer.

Use Default Timeout.

Test

{proxy+} -> ANY -> Test:

Method: GET

Path: amazons

Stage Variables:

vpcLinkId: xemf89

Test.

Should get 200.

Deploy API

API -> themyscira -> / -> Actions -> Deploy API

Deployment Stage: New Stage

Stage name: test

Stage Settings

Stage Variables

Add Stage Variables.

Name: vpcLinkId

Value: xemf89

Make sure to click the check sign, otherwise they won't be saved and the invocations will get "Internal server error"

Back to Settings -> Save Changes.