|
| 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 | +} |
0 commit comments