Skip to content

Commit 1006fb0

Browse files
committed
Add Datadog example for streaming mode
1 parent 8862cf1 commit 1006fb0

File tree

16 files changed

+5949
-6
lines changed

16 files changed

+5949
-6
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Welcome to your CDK TypeScript project
2+
3+
This is a blank project for CDK development with TypeScript.
4+
5+
The `cdk.json` file tells the CDK Toolkit how to execute your app.
6+
7+
## Useful commands
8+
9+
* `npm run build` compile typescript to js
10+
* `npm run watch` watch for changes and compile
11+
* `npm run test` perform the jest unit tests
12+
* `npx cdk deploy` deploy this stack to your default AWS account/region
13+
* `npx cdk diff` compare deployed stack with current state
14+
* `npx cdk synth` emits the synthesized CloudFormation template
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { App, CfnOutput, Duration, Stack, StackProps } from "aws-cdk-lib";
2+
import {
3+
DockerImageFunction,
4+
DockerImageCode,
5+
FunctionUrlAuthType,
6+
Architecture,
7+
InvokeMode,
8+
} from "aws-cdk-lib/aws-lambda";
9+
import * as path from "path";
10+
11+
const app = new App();
12+
13+
class LwaStack extends Stack {
14+
constructor(scope: App, id: string, props?: StackProps) {
15+
super(scope, id, props);
16+
17+
const lwa_lambda = new DockerImageFunction(this, id, {
18+
code: DockerImageCode.fromImageAsset(
19+
path.join(__dirname, "../../lambda-asset"),
20+
{
21+
cacheDisabled: true,
22+
}
23+
),
24+
functionName: id + "-lambda",
25+
timeout: Duration.seconds(9),
26+
// Optional: Specify the architecture of the docker image if it's not X86_64
27+
architecture: Architecture.ARM_64,
28+
});
29+
30+
const functionUrl = lwa_lambda.addFunctionUrl({
31+
authType: FunctionUrlAuthType.NONE,
32+
invokeMode: InvokeMode.RESPONSE_STREAM,
33+
});
34+
35+
new CfnOutput(this, "LambdaFunctionUrl", {
36+
value: functionUrl.url,
37+
description: "The Lambda Function URL",
38+
});
39+
40+
lwa_lambda.addEnvironment(
41+
"AWS_LWA_LAMBDA_RUNTIME_API_PROXY",
42+
"127.0.0.1:9002"
43+
);
44+
45+
lwa_lambda.addEnvironment("AWS_LWA_INVOKE_MODE", "response_stream");
46+
lwa_lambda.addEnvironment("DD_TRACE_PARTIAL_FLUSH_MIN_SPANS", "1");
47+
lwa_lambda.addEnvironment("DD_TRACE_PARTIAL_FLUSH_ENABLED", "false");
48+
lwa_lambda.addEnvironment("DD_API_KEY", process.env.DD_API_KEY || "");
49+
lwa_lambda.addEnvironment("DD_SERVICE", id);
50+
}
51+
}
52+
53+
new LwaStack(app, "lwa-stack", {});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"acknowledged-issue-numbers": [
3+
32775
4+
]
5+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"app": "npx ts-node --prefer-ts-exts app/cdk.ts",
3+
"watch": {
4+
"include": ["**"],
5+
"exclude": [
6+
"README.md",
7+
"cdk*.json",
8+
"**/*.d.ts",
9+
"**/*.js",
10+
"tsconfig.json",
11+
"package*.json",
12+
"yarn.lock",
13+
"node_modules",
14+
"test"
15+
]
16+
},
17+
"context": {
18+
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
19+
"@aws-cdk/core:checkSecretUsage": true,
20+
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
21+
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
22+
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
23+
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
24+
"@aws-cdk/aws-iam:minimizePolicies": true,
25+
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
26+
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
27+
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
28+
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
29+
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
30+
"@aws-cdk/core:enablePartitionLiterals": true,
31+
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
32+
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
33+
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
34+
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
35+
"@aws-cdk/aws-route53-patters:useCertificate": true,
36+
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
37+
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
38+
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
39+
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
40+
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
41+
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
42+
"@aws-cdk/aws-redshift:columnId": true,
43+
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
44+
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
45+
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
46+
"@aws-cdk/aws-kms:aliasNameRef": true,
47+
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
48+
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
49+
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
50+
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
51+
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
52+
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true,
53+
"@aws-cdk/aws-rds:auroraClusterChangeScopeOfInstanceParameterGroupWithEachParameters": true,
54+
"@aws-cdk/aws-appsync:useArnForSourceApiAssociationIdentifier": true,
55+
"@aws-cdk/aws-rds:preventRenderingDeprecatedCredentials": true,
56+
"@aws-cdk/aws-codepipeline-actions:useNewDefaultBranchForCodeCommitSource": true,
57+
"@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction": true,
58+
"@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse": true,
59+
"@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2": true,
60+
"@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope": true,
61+
"@aws-cdk/aws-eks:nodegroupNameAttribute": true,
62+
"@aws-cdk/aws-ec2:ebsDefaultGp3Volume": true,
63+
"@aws-cdk/aws-ecs:removeDefaultDeploymentAlarm": true,
64+
"@aws-cdk/custom-resources:logApiResponseDataPropertyTrueDefault": false,
65+
"@aws-cdk/aws-s3:keepNotificationInImportedBucket": false,
66+
"@aws-cdk/aws-ecs:reduceEc2FargateCloudWatchPermissions": true,
67+
"@aws-cdk/aws-ec2:ec2SumTImeoutEnabled": true,
68+
"@aws-cdk/aws-appsync:appSyncGraphQLAPIScopeLambdaPermission": true,
69+
"@aws-cdk/aws-rds:setCorrectValueForDatabaseInstanceReadReplicaInstanceResourceId": true,
70+
"@aws-cdk/core:cfnIncludeRejectComplexResourceUpdateCreatePolicyIntrinsics": true,
71+
"@aws-cdk/aws-lambda-nodejs:sdkV3ExcludeSmithyPackages": true
72+
}
73+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
roots: ['<rootDir>/test'],
4+
testMatch: ['**/*.test.ts'],
5+
transform: {
6+
'^.+\\.tsx?$': 'ts-jest'
7+
}
8+
};

0 commit comments

Comments
 (0)