Skip to content

Commit 7b70cb8

Browse files
committed
update
1 parent 9fb2879 commit 7b70cb8

15 files changed

Lines changed: 314 additions & 17 deletions

File tree

integration-tests/bin/app.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
import 'source-map-support/register';
33
import * as cdk from 'aws-cdk-lib';
44
import * as os from 'os';
5-
import { BaseStack } from '../lib/base-stack';
5+
import { BaseNodeStack } from '../lib/base-node-stack';
6+
import { BasePythonStack } from '../lib/base-python-stack';
7+
import { BaseJavaStack } from '../lib/base-java-stack';
8+
import { BaseDotnetStack } from '../lib/base-dotnet-stack';
69

710
const app = new cdk.App();
811

@@ -36,7 +39,19 @@ function getIdentifier(): string {
3639

3740
const identifier = getIdentifier();
3841

39-
new BaseStack(app, `integ-${identifier}-base`, {
42+
new BaseNodeStack(app, `integ-${identifier}-base-node`, {
43+
env,
44+
});
45+
46+
new BasePythonStack(app, `integ-${identifier}-base-python`, {
47+
env,
48+
});
49+
50+
new BaseJavaStack(app, `integ-${identifier}-base-java`, {
51+
env,
52+
});
53+
54+
new BaseDotnetStack(app, `integ-${identifier}-base-dotnet`, {
4055
env,
4156
});
4257

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Amazon.Lambda.Core;
2+
using System.Collections.Generic;
3+
4+
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
5+
6+
namespace BaseDotnet
7+
{
8+
public class Function
9+
{
10+
public Dictionary<string, object> FunctionHandler(Dictionary<string, object> input, ILambdaContext context)
11+
{
12+
Console.WriteLine("Hello world!");
13+
14+
return new Dictionary<string, object>
15+
{
16+
{ "statusCode", 200 }
17+
};
18+
}
19+
}
20+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import com.amazonaws.services.lambda.runtime.Context;
2+
import com.amazonaws.services.lambda.runtime.RequestHandler;
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class Handler implements RequestHandler<Map<String, Object>, Map<String, Object>> {
7+
@Override
8+
public Map<String, Object> handleRequest(Map<String, Object> event, Context context) {
9+
System.out.println("Hello world!");
10+
11+
Map<String, Object> response = new HashMap<>();
12+
response.put("statusCode", 200);
13+
return response;
14+
}
15+
}
File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def handler(event, context):
2+
print('Hello world!')
3+
return {
4+
'statusCode': 200
5+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import * as lambda from 'aws-cdk-lib/aws-lambda';
3+
import { Construct } from 'constructs';
4+
import { createLogGroup, datadogEnvVariables, secretPolicy, getExtensionLayer, getDotnetLayer } from './util';
5+
6+
export class BaseDotnetStack extends cdk.Stack {
7+
constructor(scope: Construct, id: string, props: cdk.StackProps) {
8+
super(scope, id, props);
9+
10+
const dotnetFunctionName = `${id}-dotnet-function`
11+
const dotnetFunction = new lambda.Function(this, dotnetFunctionName, {
12+
runtime: lambda.Runtime.DOTNET_8,
13+
architecture: lambda.Architecture.ARM_64,
14+
handler: 'BaseDotnet::BaseDotnet.Function::FunctionHandler',
15+
code: lambda.Code.fromAsset('./lambda/base-dotnet'),
16+
functionName: dotnetFunctionName,
17+
timeout: cdk.Duration.seconds(30),
18+
memorySize: 512,
19+
environment: {
20+
...datadogEnvVariables,
21+
DD_SERVICE: dotnetFunctionName,
22+
DD_TRACE_ENABLED: 'true',
23+
AWS_LAMBDA_EXEC_WRAPPER: '/opt/datadog_wrapper',
24+
CORECLR_ENABLE_PROFILING: '1',
25+
CORECLR_PROFILER: '{846F5F1C-F9AE-4B07-969E-05C26BC060D8}',
26+
CORECLR_PROFILER_PATH: '/opt/datadog/Datadog.Trace.ClrProfiler.Native.so',
27+
DD_DOTNET_TRACER_HOME: '/opt/datadog',
28+
},
29+
logGroup: createLogGroup(this, dotnetFunctionName)
30+
});
31+
dotnetFunction.addToRolePolicy(secretPolicy)
32+
dotnetFunction.addLayers(getExtensionLayer(this));
33+
dotnetFunction.addLayers(getDotnetLayer(this));
34+
}
35+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import * as lambda from 'aws-cdk-lib/aws-lambda';
3+
import { Construct } from 'constructs';
4+
import { createLogGroup, datadogEnvVariables, secretPolicy, getExtensionLayer, getJavaLayer } from './util';
5+
6+
export class BaseJavaStack extends cdk.Stack {
7+
constructor(scope: Construct, id: string, props: cdk.StackProps) {
8+
super(scope, id, props);
9+
10+
const javaFunctionName = `${id}-java-function`
11+
const javaFunction = new lambda.Function(this, javaFunctionName, {
12+
runtime: lambda.Runtime.JAVA_21,
13+
architecture: lambda.Architecture.ARM_64,
14+
handler: 'Handler::handleRequest',
15+
code: lambda.Code.fromAsset('./lambda/base-java'),
16+
functionName: javaFunctionName,
17+
timeout: cdk.Duration.seconds(30),
18+
memorySize: 512,
19+
environment: {
20+
...datadogEnvVariables,
21+
DD_SERVICE: javaFunctionName,
22+
DD_TRACE_ENABLED: 'true',
23+
AWS_LAMBDA_EXEC_WRAPPER: '/opt/datadog_wrapper',
24+
},
25+
logGroup: createLogGroup(this, javaFunctionName)
26+
});
27+
javaFunction.addToRolePolicy(secretPolicy)
28+
javaFunction.addLayers(getExtensionLayer(this));
29+
javaFunction.addLayers(getJavaLayer(this));
30+
}
31+
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ import * as lambda from 'aws-cdk-lib/aws-lambda';
33
import { Construct } from 'constructs';
44
import { createLogGroup, datadogEnvVariables, secretPolicy, getExtensionLayer, getNode20Layer } from './util';
55

6-
export class BaseStack extends cdk.Stack {
6+
export class BaseNodeStack extends cdk.Stack {
77
constructor(scope: Construct, id: string, props: cdk.StackProps) {
88
super(scope, id, props);
99

10-
const functionName = `${id}-node-function`
11-
const nodeFunction = new lambda.Function(this, functionName, {
10+
const nodeFunctionName = `${id}-node-function`
11+
const nodeFunction = new lambda.Function(this, nodeFunctionName, {
1212
runtime: lambda.Runtime.NODEJS_20_X,
1313
architecture: lambda.Architecture.ARM_64,
1414
handler: '/opt/nodejs/node_modules/datadog-lambda-js/handler.handler',
15-
code: lambda.Code.fromAsset('./lambda/base'),
16-
functionName: functionName,
15+
code: lambda.Code.fromAsset('./lambda/base-node'),
16+
functionName: nodeFunctionName,
1717
timeout: cdk.Duration.seconds(30),
1818
memorySize: 256,
1919
environment: {
2020
...datadogEnvVariables,
21-
DD_SERVICE: functionName,
21+
DD_SERVICE: nodeFunctionName,
2222
DD_TRACE_ENABLED: 'true',
2323
DD_LAMBDA_HANDLER: 'index.handler',
2424
},
25-
logGroup: createLogGroup(this, functionName)
25+
logGroup: createLogGroup(this, nodeFunctionName)
2626
});
2727
nodeFunction.addToRolePolicy(secretPolicy)
2828
nodeFunction.addLayers(getExtensionLayer(this));
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import * as lambda from 'aws-cdk-lib/aws-lambda';
3+
import { Construct } from 'constructs';
4+
import { createLogGroup, datadogEnvVariables, secretPolicy, getExtensionLayer, getPython312Layer } from './util';
5+
6+
export class BasePythonStack extends cdk.Stack {
7+
constructor(scope: Construct, id: string, props: cdk.StackProps) {
8+
super(scope, id, props);
9+
10+
const pythonFunctionName = `${id}-python-function`
11+
const pythonFunction = new lambda.Function(this, pythonFunctionName, {
12+
runtime: lambda.Runtime.PYTHON_3_12,
13+
architecture: lambda.Architecture.ARM_64,
14+
handler: '/opt/python/lib/python3.12/site-packages/datadog_lambda/handler.handler',
15+
code: lambda.Code.fromAsset('./lambda/base-python'),
16+
functionName: pythonFunctionName,
17+
timeout: cdk.Duration.seconds(30),
18+
memorySize: 256,
19+
environment: {
20+
...datadogEnvVariables,
21+
DD_SERVICE: pythonFunctionName,
22+
DD_TRACE_ENABLED: 'true',
23+
DD_LAMBDA_HANDLER: 'handler.handler',
24+
},
25+
logGroup: createLogGroup(this, pythonFunctionName)
26+
});
27+
pythonFunction.addToRolePolicy(secretPolicy)
28+
pythonFunction.addLayers(getExtensionLayer(this));
29+
pythonFunction.addLayers(getPython312Layer(this));
30+
}
31+
}

0 commit comments

Comments
 (0)