Skip to content

Commit 4ed708a

Browse files
author
Michael Brewer
committed
docs: some more housekeeping
1 parent ae35063 commit 4ed708a

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

aws_lambda_powertools/utilities/data_classes/alb_event.py

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class ALBEventRequestContext(DictWrapper):
77
@property
88
def elb_target_group_arn(self) -> str:
9+
"""Target group arn for your Lambda function"""
910
return self["requestContext"]["elb"]["targetGroupArn"]
1011

1112

@@ -15,6 +16,7 @@ class ALBEvent(BaseProxyEvent):
1516
Documentation:
1617
--------------
1718
- https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html
19+
- https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html
1820
"""
1921

2022
@property

docs/utilities/data_classes.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,27 @@ For example, if your Lambda function is being triggered by an API Gateway proxy
2929

3030
=== "app.py"
3131

32-
```python hl_lines="1 4"
33-
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
32+
```python hl_lines="1 4"
33+
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
3434

35-
def lambda_handler(event: dict, context):
36-
event = APIGatewayProxyEvent(event)
37-
if 'helloworld' in event.path and event.http_method == 'GET':
38-
do_something_with(event.body, user)
39-
```
35+
def lambda_handler(event: dict, context):
36+
event = APIGatewayProxyEvent(event)
37+
if 'helloworld' in event.path and event.http_method == 'GET':
38+
do_something_with(event.body, user)
39+
```
4040

41-
=== "app.py using event_source decorator"
41+
Same example as above, but using the `event_source` decorator
4242

43-
```python hl_lines="1 3"
44-
from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewayProxyEvent
43+
=== "app.py"
4544

46-
@event_source(data_class=APIGatewayProxyEvent)
47-
def lambda_handler(event: APIGatewayProxyEvent, context):
48-
if 'helloworld' in event.path and event.http_method == 'GET':
49-
do_something_with(event.body, user)
50-
```
45+
```python hl_lines="1 3"
46+
from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewayProxyEvent
47+
48+
@event_source(data_class=APIGatewayProxyEvent)
49+
def lambda_handler(event: APIGatewayProxyEvent, context):
50+
if 'helloworld' in event.path and event.http_method == 'GET':
51+
do_something_with(event.body, user)
52+
```
5153

5254
**Autocomplete with self-documented properties and methods**
5355

@@ -93,10 +95,9 @@ from aws_lambda_powertools.utilities.data_classes import event_source, APIGatewa
9395

9496
@event_source(data_class=APIGatewayProxyEvent)
9597
def lambda_handler(event: APIGatewayProxyEvent, context):
96-
request_context = event.request_context
97-
identity = request_context.identity
98-
9998
if "helloworld" in event.path and event.http_method == "GET":
99+
request_context = event.request_context
100+
identity = request_context.identity
100101
user = identity.user
101102
do_something_with(event.json_body, user)
102103
```
@@ -260,7 +261,6 @@ from aws_lambda_powertools.utilities.data_classes import event_source, CodePipel
260261

261262
logger = Logger()
262263

263-
264264
@event_source(data_class=CodePipelineJobEvent)
265265
def lambda_handler(event, context):
266266
"""The Lambda function handler

0 commit comments

Comments
 (0)