-
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.
feat: add skeleton of step function class and example stack
- Loading branch information
Showing
9 changed files
with
141 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.ts | ||
!*.d.ts | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
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,3 @@ | ||
# Datadog CDK TypeScript Example | ||
|
||
This example is used to test the [datadog-cdk-constructs](https://github.com/DataDog/datadog-cdk-constructs) v2 library for Step Functions. The Step Functions support is still in development. Once it's ready, this example will be merged into the `typescript-stack` so that a single stack can be used for testing both Lambda functions and Step Functions, making it easier for CDK construct developers to test their changes. The two examples are kept separate for now so the incomplete Step Function support won't break the testing of Lambda functions. |
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,7 @@ | ||
#!/usr/bin/env node | ||
import * as cdk from "aws-cdk-lib"; | ||
import { CdkStepFunctionsTypeScriptStack } from "../lib/cdk-step-functions-typescript-stack"; | ||
|
||
const app = new cdk.App(); | ||
new CdkStepFunctionsTypeScriptStack(app, "CdkStepFunctionsTypeScriptStack", {}); | ||
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,39 @@ | ||
{ | ||
"app": "npx ts-node --prefer-ts-exts bin/index.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-lambda:recognizeLayerVersion": true, | ||
"@aws-cdk/core:checkSecretUsage": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
], | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true, | ||
"@aws-cdk/aws-iam:minimizePolicies": true, | ||
"@aws-cdk/core:validateSnapshotRemovalPolicy": true, | ||
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true, | ||
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true, | ||
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true, | ||
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true, | ||
"@aws-cdk/core:enablePartitionLiterals": true, | ||
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true, | ||
"@aws-cdk/aws-iam:standardizedServicePrincipals": true, | ||
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
examples/step-functions-typescript-stack/lib/cdk-step-functions-typescript-stack.ts
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,40 @@ | ||
import * as lambda from "aws-cdk-lib/aws-lambda"; | ||
import * as sfn from "aws-cdk-lib/aws-stepfunctions"; | ||
import { Duration, Stack, StackProps } from "aws-cdk-lib"; | ||
import { Construct } from "constructs"; | ||
import { DatadogStepFunctions } from "datadog-cdk-constructs-v2"; | ||
import * as tasks from "aws-cdk-lib/aws-stepfunctions-tasks"; | ||
|
||
export class CdkStepFunctionsTypeScriptStack extends Stack { | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
super(scope, id, props); | ||
|
||
console.log("Creating Hello World TypeScript stack"); | ||
|
||
const helloLambdaFunction = new lambda.Function(this, "hello-python", { | ||
runtime: lambda.Runtime.PYTHON_3_12, | ||
timeout: Duration.seconds(10), | ||
memorySize: 256, | ||
code: lambda.Code.fromAsset("../lambda/python", { | ||
bundling: { | ||
image: lambda.Runtime.PYTHON_3_12.bundlingImage, | ||
command: ["bash", "-c", "pip install -r requirements.txt -t /asset-output && cp -aT . /asset-output"], | ||
}, | ||
}), | ||
handler: "hello.lambda_handler", | ||
}); | ||
|
||
const stateMachine = new sfn.StateMachine(this, "MyStateMachine", { | ||
definitionBody: sfn.DefinitionBody.fromChainable( | ||
new tasks.LambdaInvoke(this, "MyLambdaTask", { | ||
lambdaFunction: helloLambdaFunction, | ||
}).next(new sfn.Succeed(this, "GreetedWorld")), | ||
), | ||
}); | ||
|
||
console.log("Instrumenting Step Functions in TypeScript stack with Datadog"); | ||
|
||
const datadogSfn = new DatadogStepFunctions(this, "Datadog", {}); | ||
datadogSfn.addStateMachines([stateMachine]); | ||
} | ||
} |
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,20 @@ | ||
{ | ||
"name": "typescript-stack", | ||
"version": "1.0.0", | ||
"bin": { | ||
"cdk-typescript": "bin/index.js" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.8.8", | ||
"aws-cdk": "^2.134.0", | ||
"ts-node": "^10.9.1", | ||
"typescript": "~5.2.2" | ||
}, | ||
"dependencies": { | ||
"@aws-cdk/aws-lambda-go-alpha": "^2.134.0-alpha.0", | ||
"@aws-cdk/aws-lambda-python-alpha": "^2.134.0-alpha.0", | ||
"aws-cdk-lib": "^2.134.0", | ||
"constructs": "^10.3.0", | ||
"datadog-cdk-constructs-v2": "^1.15.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed | ||
* under the Apache License Version 2.0. | ||
* | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2021 Datadog, Inc. | ||
*/ | ||
|
||
import * as sfn from "aws-cdk-lib/aws-stepfunctions"; | ||
import { Construct } from "constructs"; | ||
import { DatadogStepFunctionsProps } from "./index"; | ||
|
||
export class DatadogStepFunctions extends Construct { | ||
scope: Construct; | ||
props: DatadogStepFunctionsProps; | ||
constructor(scope: Construct, id: string, props: DatadogStepFunctionsProps) { | ||
super(scope, id); | ||
this.scope = scope; | ||
this.props = props; | ||
} | ||
|
||
public addStateMachines(_stateMachines: sfn.StateMachine[], _construct?: Construct): void {} | ||
} |
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