Skip to content

Commit

Permalink
add example for python stack
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanista committed Dec 4, 2023
1 parent 66ce365 commit cb6382d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ dist/
cdk.out/
__pycache__/
obj/
bin/
bin/
.idea/
34 changes: 32 additions & 2 deletions examples/python-stack/cdk_python/cdk_python_stack.py
Original file line number Diff line number Diff line change
@@ -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,
)
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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"),
Expand All @@ -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])

0 comments on commit cb6382d

Please sign in to comment.