Skip to content

Commit d0af58b

Browse files
authored
feature: Input validation utility (#22)
1 parent 7f262e9 commit d0af58b

File tree

21 files changed

+321
-125
lines changed

21 files changed

+321
-125
lines changed

Pipfile.lock

Lines changed: 80 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ The project is a template project that is based on my AWS Lambda handler cookboo
2525

2626
This project provides a working, open source based, AWS Lambda handler skeleton Python code including DEPLOYMENT code with CDK and a pipeline.
2727

28-
The project deploys an API GW with an AWS Lambda integration under the path GET /api/service/.
28+
The project deploys an API GW with an AWS Lambda integration under the path POST /api/service/.
2929

3030
The AWS Lambda handler embodies Serverless best practices and has all the bells and whistles for a proper production ready handler.
3131

3232

3333

3434
## CDK Deployment
35-
The CDK code create an API GW with a path of /api/service which triggers the lambda on 'GET' requests.
35+
The CDK code create an API GW with a path of /api/service which triggers the lambda on 'POST' requests.
3636

3737
The AWS Lambda handler uses a Lambda layer optimization which takes all the packages under the [packages] section in the Pipfile and downloads them in via a Docker instance.
3838

@@ -49,7 +49,7 @@ The utilities cover multiple aspect of a production-ready service, including:
4949
2. [Observability: Monitoring and Tracing](https://www.ranthebuilder.cloud/post/aws-lambda-cookbook-elevate-your-handler-s-code-part-2-observability)
5050
3. [Observability: Business Domain Metrics](https://www.ranthebuilder.cloud/post/aws-lambda-cookbook-elevate-your-handler-s-code-part-3-business-domain-observability)
5151
4. [Environment variables](https://www.ranthebuilder.cloud/post/aws-lambda-cookbook-environment-variables)
52-
5. Input validation
52+
5. [Input validation](https://www.ranthebuilder.cloud/post/aws-lambda-cookbook-elevate-your-handler-s-code-part-5-input-validation)
5353
6. Features flags & dynamic configuration
5454

5555
#

cdk/aws_lambda_handler_cookbook/service_stack/cookbook_construct.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self, scope: Construct, id_: str) -> None:
3737

3838
self.rest_api = self._build_api_gw()
3939
api_resource: aws_apigateway.Resource = self.rest_api.root.add_resource('api').add_resource(GW_RESOURCE)
40-
self.__add_get_lambda_integration(api_resource)
40+
self.__add_post_lambda_integration(api_resource)
4141

4242
def _build_api_gw(self) -> aws_apigateway.LambdaRestApi:
4343
rest_api: aws_apigateway.LambdaRestApi = aws_apigateway.RestApi(
@@ -69,10 +69,10 @@ def _build_common_layer(self) -> PythonLayerVersion:
6969
removal_policy=RemovalPolicy.DESTROY,
7070
)
7171

72-
def __add_get_lambda_integration(self, api_name: aws_apigateway.Resource):
72+
def __add_post_lambda_integration(self, api_name: aws_apigateway.Resource):
7373
lambda_function = _lambda.Function(
7474
self,
75-
'CookBookGet',
75+
'CookBookPost',
7676
runtime=_lambda.Runtime.PYTHON_3_8,
7777
code=_lambda.Code.from_asset(BUILD_FOLDER),
7878
handler='service.handlers.my_handler.my_handler',
@@ -89,5 +89,5 @@ def __add_get_lambda_integration(self, api_name: aws_apigateway.Resource):
8989
layers=[self.common_layer],
9090
)
9191

92-
# GET /api/service/
93-
api_name.add_method(http_method='GET', integration=aws_apigateway.LambdaIntegration(handler=lambda_function))
92+
# POST /api/service/
93+
api_name.add_method(http_method='POST', integration=aws_apigateway.LambdaIntegration(handler=lambda_function))

cdk/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
install_requires=[
2626
'aws-cdk-lib>=2.0.0',
2727
'constructs>=10.0.0',
28-
'aws-cdk.aws-lambda-python-alpha==2.16.0a0',
28+
'aws-cdk.aws-lambda-python-alpha==2.19.0-alpha.0',
2929
],
3030
)

0 commit comments

Comments
 (0)