From cb6382d10ea41886c3ac385d1ae95c98fc450413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?jordan=20gonz=C3=A1lez?= <30836115+duncanista@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:16:47 -0500 Subject: [PATCH] add example for python stack --- .gitignore | 3 +- .../cdk_python/cdk_python_stack.py | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index be5fb689..f6cd9ba9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ dist/ cdk.out/ __pycache__/ obj/ -bin/ \ No newline at end of file +bin/ +.idea/ \ No newline at end of file diff --git a/examples/python-stack/cdk_python/cdk_python_stack.py b/examples/python-stack/cdk_python/cdk_python_stack.py index 5ebcdf3d..8d420dd7 100644 --- a/examples/python-stack/cdk_python/cdk_python_stack.py +++ b/examples/python-stack/cdk_python/cdk_python_stack.py @@ -1,7 +1,9 @@ from aws_cdk import ( aws_lambda as _lambda, aws_lambda_go_alpha as go, + aws_apigatewayv2 as apigwv2, BundlingOptions, + BundlingOutput, Duration, Stack, ) @@ -21,6 +23,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None: "hello-node", runtime=_lambda.Runtime.NODEJS_20_X, timeout=Duration.seconds(10), + memory_size=256, code=_lambda.Code.from_asset( "../lambda/node", bundling=BundlingOptions( @@ -41,6 +44,7 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None: "hello-python", runtime=_lambda.Runtime.PYTHON_3_11, timeout=Duration.seconds(10), + memory_size=256, code=_lambda.Code.from_asset( "../lambda/python", bundling=BundlingOptions( @@ -66,11 +70,37 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None: ), ) + hello_dotnet = _lambda.Function( + self, + "hello-dotnet", + runtime=_lambda.Runtime.DOTNET_6, + handler="HelloWorld::HelloWorld.Handler::SayHi", + timeout=Duration.seconds(10), + memory_size=256, + code=_lambda.Code.from_asset( + "../lambda/dotnet", + bundling=BundlingOptions( + image=_lambda.Runtime.DOTNET_6.bundling_image, + command=[ + '/bin/sh', + '-c', + ' dotnet tool install -g Amazon.Lambda.Tools' + + ' && dotnet build' + + ' && dotnet lambda package --output-package /asset-output/function.zip' + ], + user="root", + output_type=BundlingOutput.ARCHIVED + ), + ), + + ) + datadog = Datadog( self, "Datadog", + dotnet_layer_version=13, node_layer_version=101, - python_layer_version=84, + python_layer_version=83, extension_layer_version=51, add_layers=True, api_key=os.getenv("DD_API_KEY"), @@ -79,4 +109,4 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None: flush_metrics_to_logs=True, site="datadoghq.com", ) - datadog.add_lambda_functions([hello_node, hello_python, hello_go]) + datadog.add_lambda_functions([hello_node, hello_python, hello_go, hello_dotnet])