-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add integration test for Python
- Loading branch information
Showing
7 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from constructs import Construct | ||
from datadog_cdk_constructs_v2 import Datadog, DatadogProps | ||
from aws_cdk import App | ||
|
||
from lambda_python_stack_base import LambdaPythonStackBase | ||
|
||
class LambdaPythonStack(LambdaPythonStackBase): | ||
def __init__(self, scope: Construct, id: str, **kwargs) -> None: | ||
super().__init__(scope, id, **kwargs) | ||
|
||
datadog = Datadog( | ||
self, | ||
"Datadog", | ||
dotnet_layer_version=15, | ||
node_layer_version=107, | ||
python_layer_version=89, | ||
extension_layer_version=55, | ||
add_layers=True, | ||
api_key="1234", | ||
enable_datadog_tracing=True, | ||
enable_datadog_asm=True, | ||
flush_metrics_to_logs=True, | ||
site="datadoghq.com", | ||
) | ||
|
||
# Ensure DatadogProps can be imported properly | ||
props = DatadogProps() | ||
datadog.add_lambda_functions(self.lambdaFunctions) | ||
|
||
app = App() | ||
LambdaPythonStack(app, "LambdaPythonStack") | ||
app.synth() | ||
|
92 changes: 92 additions & 0 deletions
92
integration_tests/stacks/python/lambda_python_stack_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
from aws_cdk import ( | ||
aws_lambda as _lambda, | ||
aws_lambda_go_alpha as go, | ||
BundlingOptions, | ||
BundlingOutput, | ||
Duration, | ||
Stack, | ||
) | ||
from constructs import Construct | ||
|
||
|
||
class LambdaPythonStackBase(Stack): | ||
def __init__(self, scope: Construct, id: str, **kwargs) -> None: | ||
super().__init__(scope, id, **kwargs) | ||
|
||
hello_node = _lambda.Function( | ||
self, | ||
"hello-node", | ||
runtime=_lambda.Runtime.NODEJS_20_X, | ||
timeout=Duration.seconds(10), | ||
memory_size=256, | ||
code=_lambda.Code.from_asset( | ||
"../examples/lambda/node", | ||
bundling=BundlingOptions( | ||
image=_lambda.Runtime.NODEJS_20_X.bundling_image, | ||
command=[ | ||
"bash", | ||
"-c", | ||
"cp -aT . /asset-output && npm install --prefix /asset-output", | ||
], | ||
user="root", | ||
), | ||
), | ||
handler="hello.lambda_handler", | ||
) | ||
|
||
hello_python = _lambda.Function( | ||
self, | ||
"hello-python", | ||
runtime=_lambda.Runtime.PYTHON_3_11, | ||
timeout=Duration.seconds(10), | ||
memory_size=256, | ||
code=_lambda.Code.from_asset( | ||
"../examples/lambda/python", | ||
bundling=BundlingOptions( | ||
image=_lambda.Runtime.PYTHON_3_11.bundling_image, | ||
command=[ | ||
"bash", | ||
"-c", | ||
"pip install -r requirements.txt -t /asset-output && cp -aT . /asset-output", | ||
], | ||
), | ||
), | ||
handler="hello.lambda_handler", | ||
) | ||
|
||
hello_go = go.GoFunction( | ||
self, | ||
"hello-go", | ||
entry="../examples/lambda/go/hello.go", | ||
runtime=_lambda.Runtime.PROVIDED_AL2, | ||
timeout=Duration.seconds(10), | ||
bundling=go.BundlingOptions( | ||
go_build_flags=['-ldflags "-s -w"'], | ||
), | ||
) | ||
|
||
hello_dotnet = _lambda.Function( | ||
self, | ||
"hello-dotnet", | ||
runtime=_lambda.Runtime.DOTNET_8, | ||
handler="HelloWorld::HelloWorld.Handler::SayHi", | ||
timeout=Duration.seconds(10), | ||
memory_size=256, | ||
code=_lambda.Code.from_asset( | ||
"../examples/lambda/dotnet", | ||
bundling=BundlingOptions( | ||
image=_lambda.Runtime.DOTNET_8.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 | ||
), | ||
), | ||
) | ||
|
||
self.lambdaFunctions = [hello_node, hello_python, hello_go, hello_dotnet] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
aws-cdk-lib~=2.134.0 | ||
aws-cdk.aws-lambda-go-alpha~=2.134.0a0 | ||
constructs~=10.0.5 | ||
datadog_cdk_constructs_v2~=1.13.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters