Skip to content

Commit 3bcba99

Browse files
committed
docs: add example infra
1 parent 01bb059 commit 3bcba99

File tree

1 file changed

+55
-7
lines changed

1 file changed

+55
-7
lines changed

docs/core/event_handler/api_gateway.md

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Event handler for Amazon API Gateway REST/HTTP APIs and Application Loader Balan
77

88
!!! todo "Change proxy types enum to match PascalCase"
99

10+
!!! todo "Update `route` methods to include an example in docstring to improve developer experience"
11+
1012
### Key Features
1113

1214
* Lightweight routing to reduce boilerplate for API Gateway REST/HTTP API and ALB
@@ -15,20 +17,66 @@ Event handler for Amazon API Gateway REST/HTTP APIs and Application Loader Balan
1517
* Built-in support for Decimals JSON encoding
1618
* Support for dynamic path expressions
1719

18-
> Rest API simplification with function returns a Dict
19-
> Support function returns a Response object which give fine-grained control of the headers
20-
21-
2220
## Getting started
2321

24-
!!! todo "Supported event types"
25-
2622
### Required resources
2723

28-
!!! todo "API Gateway proxy template"
24+
You must have an existing [API Gateway Proxy integration](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html){target="_blank"} or [ALB](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html){target="_blank"} configured to invoke your Lambda function. There is no additional permissions or dependencies required to use this utility.
25+
26+
This is the sample infrastructure we are using for the initial examples in this section.
27+
28+
=== "template.yml"
29+
30+
```yaml
31+
AWSTemplateFormatVersion: '2010-09-09'
32+
Transform: AWS::Serverless-2016-10-31
33+
Description: Hello world event handler API Gateway
34+
35+
Globals:
36+
Function:
37+
Timeout: 5
38+
Runtime: python3.8
39+
Tracing: Active
40+
Environment:
41+
Variables:
42+
LOG_LEVEL: INFO
43+
POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1
44+
POWERTOOLS_LOGGER_LOG_EVENT: true
45+
POWERTOOLS_METRICS_NAMESPACE: MyServerlessApplication
46+
POWERTOOLS_SERVICE_NAME: hello
47+
48+
Resources:
49+
HelloWorldFunction:
50+
Type: AWS::Serverless::Function
51+
Properties:
52+
Handler: app.lambda_handler
53+
CodeUri: hello_world
54+
Description: Hello World function
55+
Events:
56+
HelloUniverse:
57+
Type: Api
58+
Properties:
59+
Path: /hello
60+
Method: GET
61+
HelloYou:
62+
Type: Api
63+
Properties:
64+
Path: /hello/{name}
65+
Method: GET
66+
67+
Outputs:
68+
HelloWorldApigwURL:
69+
Description: "API Gateway endpoint URL for Prod environment for Hello World Function"
70+
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello"
71+
72+
HelloWorldFunction:
73+
Description: "Hello World Lambda Function ARN"
74+
Value: !GetAtt HelloWorldFunction.Arn
75+
```
2976

3077
### Resolver decorator
3178

79+
3280
### Path expressions
3381

3482
### CORS

0 commit comments

Comments
 (0)