Skip to content

Commit fd1c895

Browse files
committed
feat: 4 examples with Lambda Function ARN and URL
1 parent 11643ed commit fd1c895

19 files changed

+163
-11
lines changed

Makefile

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
start-01:
2-
docker-compose -f examples/01-proxy-to-all-lambda-functions/docker-compose.yml up -d
2+
docker-compose -f examples/01-all-lambda-function-arns/docker-compose.yml up -d
33

44
start-02:
5-
docker-compose -f examples/02-proxy-to-each-lambda-function/docker-compose.yml up -d
5+
docker-compose -f examples/02-one-lambda-function-arn/docker-compose.yml up -d
6+
7+
start-03:
8+
docker-compose -f examples/03-one-lambda-function-url/docker-compose.yml up -d
9+
10+
start-04:
11+
docker-compose -f examples/04-lambda-function-arn-and-url/docker-compose.yml up -d
612

713
ps:
814
docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Ports}}\t{{.Names}}"
@@ -11,10 +17,16 @@ watch:
1117
watch 'docker ps --format "table {{.ID}}\t{{.Image}}\t{{.Ports}}\t{{.Names}}"'
1218

1319
down-01:
14-
docker-compose -f examples/01-proxy-to-all-lambda-functions/docker-compose.yml down
20+
docker-compose -f examples/01-all-lambda-function-arns/docker-compose.yml down
1521

1622
down-02:
17-
docker-compose -f examples/02-proxy-to-each-lambda-function/docker-compose.yml down
23+
docker-compose -f examples/02-one-lambda-function-arn/docker-compose.yml down
24+
25+
down-03:
26+
docker-compose -f examples/03-one-lambda-function-url/docker-compose.yml down
27+
28+
down-04:
29+
docker-compose -f examples/04-lambda-function-arn-and-url/docker-compose.yml down
1830

1931
clean:
2032
docker kill $$(docker ps -q) 2> /dev/null || true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Example: Proxy To All Lambda Function ARNs
2+
3+
This is an example of a NGINX proxy to all of the AWS Lambda Function ARNs.

examples/01-proxy-to-all-lambda-functions/docker-compose.yml renamed to examples/01-all-lambda-function-arns/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
# Enable this when using NGINX Plus
1313
# dockerfile: ./docker/Dockerfile.plus
1414
volumes:
15-
- ../../examples/01-proxy-to-all-lambda-functions/:/etc/nginx/conf.d/
15+
- ../../examples/01-all-lambda-function-arns/:/etc/nginx/conf.d/
1616
- ../../core:/etc/nginx/lambda
1717
ports:
1818
- "80:80"

examples/01-proxy-to-all-lambda-functions/frontend.conf renamed to examples/01-all-lambda-function-arns/frontend.conf

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ server {
44
include "lambda/lambda_ngx_apis.conf";
55
listen 80;
66

7-
# Example of all endpoint to be proxied to all AWS Lambda Function ARNs.
7+
# Example of a proxy to all of the AWS Lambda Function ARNs.
88
location / {
99
auth_request /aws/credentials/retrieval;
10-
js_content lambdagateway.redirectToLambda;
10+
js_content lambdagateway.redirectToLambdaFunctionARN;
1111
}
1212

1313
# Enable when debugging is needed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import json
2+
3+
def lambda_handler(event, context):
4+
# TODO implement
5+
return {
6+
'statusCode': 200,
7+
'body': {
8+
'request': event,
9+
'response': 'Hello from NGINX Lambda Gateway - /foo!'
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Example: Proxy To One Lambda Function ARN
2+
3+
This is an example of a NGINX proxy to one the AWS Lambda Function ARN.

examples/02-proxy-to-each-lambda-function/docker-compose.yml renamed to examples/02-one-lambda-function-arn/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
# Enable this when using NGINX Plus
1313
# dockerfile: ./docker/Dockerfile.plus
1414
volumes:
15-
- ../../examples/02-proxy-to-each-lambda-function/:/etc/nginx/conf.d/
15+
- ../../examples/02-one-lambda-function-arn/:/etc/nginx/conf.d/
1616
- ../../core:/etc/nginx/lambda
1717
ports:
1818
- "80:80"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include "lambda/lambda_ngx_http.conf";
2+
3+
server {
4+
include "lambda/lambda_ngx_apis.conf";
5+
listen 80;
6+
7+
# Example of a proxy to one AWS Lambda Function ARN.
8+
location /2015-03-31/functions/foo/invocations {
9+
auth_request /aws/credentials/retrieval;
10+
js_content lambdagateway.redirectToLambdaFunctionARN;
11+
}
12+
13+
# Enable when debugging is needed
14+
error_log /var/log/nginx/error.log debug; # Reduce severity level as required
15+
access_log /var/log/nginx/access.log main;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import json
2+
3+
def lambda_handler(event, context):
4+
# TODO implement
5+
return {
6+
'statusCode': 200,
7+
'body': {
8+
'request': event,
9+
'response': 'Hello from NGINX Lambda Gateway - /foo!'
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Example: Proxy To One Lambda Function URL
2+
3+
This is an example of a NGINX proxy to one the AWS Lambda Function URL.
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3'
2+
services:
3+
nginx_lambda:
4+
hostname: nginx_lambda
5+
container_name: nginx_lambda
6+
image: nginx_lambda
7+
build:
8+
context: ../../
9+
# Enable this when using NGINX OSS
10+
dockerfile: ./docker/Dockerfile.oss
11+
12+
# Enable this when using NGINX Plus
13+
# dockerfile: ./docker/Dockerfile.plus
14+
volumes:
15+
- ../../examples/03-one-lambda-function-url/:/etc/nginx/conf.d/
16+
- ../../core:/etc/nginx/lambda
17+
ports:
18+
- "80:80"
19+
env_file:
20+
- ../../settings.test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include "lambda/lambda_ngx_http.conf";
2+
3+
server {
4+
include "lambda/lambda_ngx_apis.conf";
5+
listen 80;
6+
7+
# Example of a proxy to one AWS Lambda Function URL.
8+
location /bar {
9+
auth_request /aws/credentials/retrieval;
10+
js_content lambdagateway.redirectToLambdaFunctionURL;
11+
}
12+
13+
# Enable when debugging is needed
14+
error_log /var/log/nginx/error.log debug; # Reduce severity level as required
15+
access_log /var/log/nginx/access.log main;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import json
2+
3+
def lambda_handler(event, context):
4+
# TODO implement
5+
return {
6+
'statusCode': 200,
7+
'body': json.dumps('Hello from NGINX Lambda Gateway - /bar!')
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Example: Proxy To The Lambda Function ARN and URL
2+
3+
This shows the combined example of NGINX proxies to the AWS Lambda Function ARN and URL.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3'
2+
services:
3+
nginx_lambda:
4+
hostname: nginx_lambda
5+
container_name: nginx_lambda
6+
image: nginx_lambda
7+
build:
8+
context: ../../
9+
# Enable this when using NGINX OSS
10+
dockerfile: ./docker/Dockerfile.oss
11+
12+
# Enable this when using NGINX Plus
13+
# dockerfile: ./docker/Dockerfile.plus
14+
volumes:
15+
- ../../examples/04-lambda-function-arn-and-url/:/etc/nginx/conf.d/
16+
- ../../core:/etc/nginx/lambda
17+
ports:
18+
- "80:80"
19+
env_file:
20+
- ../../settings.test

examples/02-proxy-to-each-lambda-function/frontend.conf renamed to examples/04-lambda-function-arn-and-url/frontend.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ server {
44
include "lambda/lambda_ngx_apis.conf";
55
listen 80;
66

7-
# Example of all endpoint to be proxied to all AWS Lambda Function ARNs.
7+
# Example of a proxy to all of the AWS Lambda Function ARNs.
88
location / {
99
auth_request /aws/credentials/retrieval;
1010
js_content lambdagateway.redirectToLambdaFunctionARN;
1111
}
1212

13-
# Example of a specific endpoint to be proxied to an AWS Lambda Function ARN.
13+
# Example of a proxy to one AWS Lambda Function ARN.
1414
location /2015-03-31/functions/foo/invocations {
1515
auth_request /aws/credentials/retrieval;
1616
js_content lambdagateway.redirectToLambdaFunctionARN;
1717
}
1818

19-
# Example of a specific endpoint to be proxied to AWS Lambda Function URL.
19+
# Example of a proxy to one AWS Lambda Function URL.
2020
location /bar {
2121
auth_request /aws/credentials/retrieval;
2222
js_content lambdagateway.redirectToLambdaFunctionURL;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import json
2+
3+
def lambda_handler(event, context):
4+
# TODO implement
5+
return {
6+
'statusCode': 200,
7+
'body': json.dumps('Hello from NGINX Lambda Gateway - /bar!')
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import json
2+
3+
def lambda_handler(event, context):
4+
# TODO implement
5+
return {
6+
'statusCode': 200,
7+
'body': {
8+
'request': event,
9+
'response': 'Hello from NGINX Lambda Gateway - /foo!'
10+
}
11+
}

examples/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# NGINX Lambda Gateway Examples
2+
3+
- [NGINX Lambda Gateway to all of the AWS Lambda Function ARNs](./01-all-lambda-function-arns/)
4+
- [NGINX Lambda Gateway to one AWS Lambda Function ARN](./02-one-lambda-function-arn/)
5+
- [NGINX Lambda Gateway to one AWS Lambda Function URL](./03-one-lambda-function-url/)
6+
- [NGINX Lambda Gateway to the AWS Lambda Function ARN and URL](./04-lambda-function-arn-and-url/)

0 commit comments

Comments
 (0)