-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extension to Lambda handlers using custom runtimes (#219)
* Add extension for custom runtimes * Add unit tests * Add integration test for provided_al2 runtime * Add integration test for provided_al2 ARM handler
- Loading branch information
Showing
10 changed files
with
2,486 additions
and
1 deletion.
There are no files selected for viewing
583 changes: 583 additions & 0 deletions
583
v2/integration_tests/snapshots/correct-lambda-provided-arm-stack-snapshot.json
Large diffs are not rendered by default.
Oops, something went wrong.
580 changes: 580 additions & 0 deletions
580
v2/integration_tests/snapshots/correct-lambda-provided-stack-snapshot.json
Large diffs are not rendered by default.
Oops, something went wrong.
583 changes: 583 additions & 0 deletions
583
v2/integration_tests/snapshots/test-lambda-provided-arm-stack-snapshot.json
Large diffs are not rendered by default.
Oops, something went wrong.
580 changes: 580 additions & 0 deletions
580
v2/integration_tests/snapshots/test-lambda-provided-stack-snapshot.json
Large diffs are not rendered by default.
Oops, something went wrong.
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,49 @@ | ||
import * as lambda from "aws-cdk-lib/aws-lambda"; | ||
import * as s3 from "aws-cdk-lib/aws-s3"; | ||
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway"; | ||
import { LogGroup } from "aws-cdk-lib/aws-logs"; | ||
import { Stack, StackProps, App } from "aws-cdk-lib"; | ||
import { Datadog } from "../../src/index"; | ||
|
||
export class ExampleStack extends Stack { | ||
constructor(scope: App, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const s3Bucket = new s3.Bucket(this, "exampleBucket", { | ||
objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED, | ||
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, | ||
}); | ||
|
||
const providedLambda = new lambda.Function(this, "HelloHandler", { | ||
runtime: lambda.Runtime.PROVIDED_AL2, | ||
code: lambda.Code.fromBucket(s3Bucket, "fake-key-for-test"), | ||
handler: "handler.handler", | ||
architecture: lambda.Architecture.ARM_64, | ||
}); | ||
|
||
s3Bucket.grantRead(providedLambda); | ||
|
||
const restLogGroup = new LogGroup(this, "restLogGroup"); | ||
new LambdaRestApi(this, "rest-test", { | ||
handler: providedLambda, | ||
deployOptions: { | ||
accessLogDestination: new LogGroupLogDestination(restLogGroup), | ||
}, | ||
}); | ||
|
||
const datadogCDK = new Datadog(this, "Datadog", { | ||
extensionLayerVersion: 49, | ||
apiKey: "1234", | ||
site: "datadoghq.com", | ||
sourceCodeIntegration: false, | ||
}); | ||
datadogCDK.addLambdaFunctions([providedLambda]); | ||
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
const env = { account: "601427279990", region: "sa-east-1" }; | ||
const stack = new ExampleStack(app, "lambda-provided-arm-stack", { env: env }); | ||
console.log("Stack name: " + stack.stackName); | ||
app.synth(); |
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,48 @@ | ||
import * as lambda from "aws-cdk-lib/aws-lambda"; | ||
import * as s3 from "aws-cdk-lib/aws-s3"; | ||
import { LambdaRestApi, LogGroupLogDestination } from "aws-cdk-lib/aws-apigateway"; | ||
import { LogGroup } from "aws-cdk-lib/aws-logs"; | ||
import { Stack, StackProps, App } from "aws-cdk-lib"; | ||
import { Datadog } from "../../src/index"; | ||
|
||
export class ExampleStack extends Stack { | ||
constructor(scope: App, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
const s3Bucket = new s3.Bucket(this, "exampleBucket", { | ||
objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_ENFORCED, | ||
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, | ||
}); | ||
|
||
const providedLambda = new lambda.Function(this, "HelloHandler", { | ||
runtime: lambda.Runtime.PROVIDED_AL2, | ||
code: lambda.Code.fromBucket(s3Bucket, "fake-key-for-test"), | ||
handler: "handler.handler", | ||
}); | ||
|
||
s3Bucket.grantRead(providedLambda); | ||
|
||
const restLogGroup = new LogGroup(this, "restLogGroup"); | ||
new LambdaRestApi(this, "rest-test", { | ||
handler: providedLambda, | ||
deployOptions: { | ||
accessLogDestination: new LogGroupLogDestination(restLogGroup), | ||
}, | ||
}); | ||
|
||
const datadogCDK = new Datadog(this, "Datadog", { | ||
extensionLayerVersion: 49, | ||
apiKey: "1234", | ||
site: "datadoghq.com", | ||
sourceCodeIntegration: false, | ||
}); | ||
datadogCDK.addLambdaFunctions([providedLambda]); | ||
datadogCDK.addForwarderToNonLambdaLogGroups([restLogGroup]); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
const env = { account: "601427279990", region: "sa-east-1" }; | ||
const stack = new ExampleStack(app, "lambda-provided-stack", { env: env }); | ||
console.log("Stack name: " + stack.stackName); | ||
app.synth(); |
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
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
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
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