# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import pathlib import aws_cdk.aws_apigatewayv2_alpha as apigatewayv2_alpha import aws_cdk.aws_apigatewayv2_integrations_alpha as apigatewayv2_integrations_alpha import aws_cdk.aws_lambda as lambda_ import aws_cdk.aws_lambda_python_alpha as lambda_python_alpha from constructs import Construct class API(Construct): def __init__( self, scope: Construct, id_: str, *, dynamodb_table_name: str, lambda_reserved_concurrency: int, ): super().__init__(scope, id_) self.lambda_function = lambda_python_alpha.PythonFunction( self, "LambdaFunction", runtime=lambda_.Runtime.PYTHON_3_7, environment={"DYNAMODB_TABLE_NAME": dynamodb_table_name}, reserved_concurrent_executions=lambda_reserved_concurrency, entry=str(pathlib.Path(__file__).parent.joinpath("runtime").resolve()), index="lambda_function.py", handler="lambda_handler", ) api_gateway_http_lambda_integration = ( apigatewayv2_integrations_alpha.HttpLambdaIntegration( "APIGatewayHTTPLambdaIntegration", handler=self.lambda_function ) ) self.api_gateway_http_api = apigatewayv2_alpha.HttpApi( self, "APIGatewayHTTPAPI", default_integration=api_gateway_http_lambda_integration, )