Skip to content

Commit 520f87f

Browse files
authored
Add docs for HTTP API Gateway (#2341)
1 parent c9a299f commit 520f87f

File tree

1 file changed

+71
-9
lines changed

1 file changed

+71
-9
lines changed

docs/clusters/networking/api-gateway.md

+71-9
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,69 @@ If your API load balancer is internal (i.e. you set `api_load_balancer_scheme: i
1212

1313
_This section applies if your API load balancer is internet-facing (which is the default, or you set `api_load_balancer_scheme: internet-facing` in your cluster configuration file before creating your cluster). If your API load balancer is internal, see the [internal load balancer](#internal-load-balancer) section below._
1414

15-
### Create an API Gateway
15+
There are two types of API Gateways that can be used when your load balancer is internet-facing: HTTP and REST. HTTP APIs are faster and less expensive, while REST APIs have more features an allow for more control. See the following section for creating an [HTTP API](#http-api), or skip to the next section for creating a [REST API](#rest-api).
16+
17+
### HTTP API
18+
19+
#### Create an API Gateway
20+
21+
Go to the [API Gateway console](https://console.aws.amazon.com/apigateway/home), select "HTTP API" under "Choose an API type", and click "Build".
22+
23+
![](https://user-images.githubusercontent.com/808475/125668597-35ad8d8e-8b5f-4274-bbb3-62ff47e5d544.png)
24+
25+
Click "Add integration".
26+
27+
![](https://user-images.githubusercontent.com/808475/125668635-f92df672-f516-45e0-a152-538aff901c0d.png)
28+
29+
Click the drop-down menu, and select "HTTP".
30+
31+
![](https://user-images.githubusercontent.com/808475/125668655-78754a51-c77a-4a03-a548-78ab991d1486.png)
32+
33+
Set the "URL endpoint" to `http://API_LOAD_BALANCER_ENDPOINT/{proxy}`. You can get your API load balancer endpoint via `cortex cluster info`; make sure to prepend `http://` and append `/{proxy}`. For example, mine is: `http://aa9f5fdabfa6446aca53a526f59bc3c5-18cd00a628421fa3.elb.us-east-1.amazonaws.com/{proxy}`.
34+
35+
Choose a name for your API (e.g. "cortex"), and click "Next".
36+
37+
![](https://user-images.githubusercontent.com/808475/125668735-b57976c7-f68e-4a28-ab2a-92cfad5b49bb.png)
38+
39+
On the next page, update the pre-populated route's resource path to `/{proxy+}`, and click "Next".
40+
41+
![](https://user-images.githubusercontent.com/808475/125668752-21aef8dd-1e75-41a5-bfc5-1e7157efbe01.png)
42+
43+
Click "Next" again.
44+
45+
![](https://user-images.githubusercontent.com/808475/125668761-8a177f6e-1977-48a2-be84-4b0df0105283.png)
46+
47+
Click "Create".
48+
49+
![](https://user-images.githubusercontent.com/808475/125668770-69fd3fbe-24e4-4a8a-8413-d50c779392c5.png)
50+
51+
Copy your "Invoke URL" for the `$default` stage
52+
53+
![](https://user-images.githubusercontent.com/808475/125668795-b18b564c-7091-432c-a4fd-a5a8bb157946.png)
54+
55+
#### Use your new endpoint
56+
57+
You may now use the "Invoke URL" in place of your API load balancer endpoint in your client. For example, this curl request:
58+
59+
```bash
60+
curl -X POST http://aa9f5fdabfa6446aca53a526f59bc3c5-18cd00a628421fa3.elb.us-east-1.amazonaws.com/hello-world
61+
```
62+
63+
Would become:
64+
65+
```bash
66+
curl -X POST https://nj3f5l96oe.execute-api.us-east-1.amazonaws.com/hello-world
67+
```
68+
69+
#### Cleanup
70+
71+
Delete the API Gateway before spinning down your Cortex cluster:
72+
73+
![](https://user-images.githubusercontent.com/808475/125668816-83bce6bf-cf0e-4835-8d18-d641eb6cdb29.png)
74+
75+
### REST API
76+
77+
#### Create an API Gateway
1678

1779
Go to the [API Gateway console](https://console.aws.amazon.com/apigateway/home), select "REST API" under "Choose an API type", and click "Build".
1880

@@ -30,7 +92,7 @@ Select "Configure as proxy resource" and "Enable API Gateway CORS", and click "C
3092

3193
![](https://user-images.githubusercontent.com/808475/80154565-ad650200-8574-11ea-8753-808cd35902e2.png)
3294

33-
Select "HTTP Proxy" and set "Endpoint URL" to "http://API_LOAD_BALANCER_ENDPOINT/{proxy}". You can get your API load balancer endpoint via `cortex cluster info`; make sure to prepend `http://` and append `/{proxy}`. For example, mine is: `http://a9eaf69fd125947abb1065f62de59047-81cdebc0275f7d96.elb.us-west-2.amazonaws.com/{proxy}`.
95+
Select "HTTP Proxy" and set "Endpoint URL" to `http://API_LOAD_BALANCER_ENDPOINT/{proxy}`. You can get your API load balancer endpoint via `cortex cluster info`; make sure to prepend `http://` and append `/{proxy}`. For example, mine is: `http://a9eaf69fd125947abb1065f62de59047-81cdebc0275f7d96.elb.us-west-2.amazonaws.com/{proxy}`.
3496

3597
Leave "Content Handling" set to "Passthrough" and Click "Save".
3698

@@ -48,21 +110,21 @@ Copy your "Invoke URL"
48110

49111
![](https://user-images.githubusercontent.com/808475/80154911-5dd30600-8575-11ea-9682-1a7328783011.png)
50112

51-
### Use your new endpoint
113+
#### Use your new endpoint
52114

53115
You may now use the "Invoke URL" in place of your API load balancer endpoint in your client. For example, this curl request:
54116

55117
```bash
56-
curl http://a9eaf69fd125947abb1065f62de59047-81cdebc0275f7d96.elb.us-west-2.amazonaws.com/hello-world -X POST -H "Content-Type: application/json" -d @sample.json
118+
curl -X POST http://a9eaf69fd125947abb1065f62de59047-81cdebc0275f7d96.elb.us-west-2.amazonaws.com/hello-world
57119
```
58120

59121
Would become:
60122

61123
```bash
62-
curl https://31qjv48rs6.execute-api.us-west-2.amazonaws.com/dev/hello-world -X POST -H "Content-Type: application/json" -d @sample.json
124+
curl -X POST https://31qjv48rs6.execute-api.us-west-2.amazonaws.com/dev/hello-world
63125
```
64126

65-
### Cleanup
127+
#### Cleanup
66128

67129
Delete the API Gateway before spinning down your Cortex cluster:
68130

@@ -110,7 +172,7 @@ Select "Configure as proxy resource" and "Enable API Gateway CORS", and click "C
110172

111173
![](https://user-images.githubusercontent.com/808475/80142124-80f2bb00-855f-11ea-8e4e-9413146e0815.png)
112174

113-
Select "VPC Link", select "Use Proxy Integration", choose your newly-created VPC Link, and set "Endpoint URL" to "http://API_LOAD_BALANCER_ENDPOINT/{proxy}". You can get your API load balancer endpoint via `cortex cluster info`; make sure to prepend `http://` and append `/{proxy}`. For example, mine is: `http://a5044e34a352d44b0945adcd455c7fa3-32fa161d3e5bcbf9.elb.us-west-2.amazonaws.com/{proxy}`. Click "Save"
175+
Select "VPC Link", select "Use Proxy Integration", choose your newly-created VPC Link, and set "Endpoint URL" to `http://API_LOAD_BALANCER_ENDPOINT/{proxy}`. You can get your API load balancer endpoint via `cortex cluster info`; make sure to prepend `http://` and append `/{proxy}`. For example, mine is: `http://a5044e34a352d44b0945adcd455c7fa3-32fa161d3e5bcbf9.elb.us-west-2.amazonaws.com/{proxy}`. Click "Save"
114176

115177
![](https://user-images.githubusercontent.com/808475/80147407-4f322200-8568-11ea-8ef5-df5164c1375f.png)
116178

@@ -131,13 +193,13 @@ Copy your "Invoke URL"
131193
You may now use the "Invoke URL" in place of your API load balancer endpoint in your client. For example, this curl request:
132194

133195
```bash
134-
curl http://a5044e34a352d44b0945adcd455c7fa3-32fa161d3e5bcbf9.elb.us-west-2.amazonaws.com/hello-world -X POST -H "Content-Type: application/json" -d @sample.json
196+
curl -X POST http://a5044e34a352d44b0945adcd455c7fa3-32fa161d3e5bcbf9.elb.us-west-2.amazonaws.com/hello-world
135197
```
136198

137199
Would become:
138200

139201
```bash
140-
curl https://lrivodooqh.execute-api.us-west-2.amazonaws.com/dev/hello-world -X POST -H "Content-Type: application/json" -d @sample.json
202+
curl -X POST https://lrivodooqh.execute-api.us-west-2.amazonaws.com/dev/hello-world
141203
```
142204

143205
### Cleanup

0 commit comments

Comments
 (0)