From eabe05c0be1c5e0e565fe18f9ec1202fa0782d40 Mon Sep 17 00:00:00 2001 From: Matthew Dean Date: Tue, 11 Aug 2026 12:55:01 -0400 Subject: [PATCH 1/2] changing scope of lookup for existing log group arn in datadog step functions construct --- src/datadog-step-functions.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/datadog-step-functions.ts b/src/datadog-step-functions.ts index 5e8a0091..f619187e 100644 --- a/src/datadog-step-functions.ts +++ b/src/datadog-step-functions.ts @@ -147,7 +147,7 @@ export class DatadogStepFunctions extends Construct { throw new Error(`logGroupArn is undefined. ${unsupportedCaseErrorMessage}`); } - logGroup = logs.LogGroup.fromLogGroupArn(this, "LogGroup", logGroupArn); + logGroup = logs.LogGroup.fromLogGroupArn(stateMachine, "LogGroup", logGroupArn); } // Configure state machine role to have permission to log to CloudWatch Logs, following From 57130b8f8157800cf5b0f7235da5065d57afd134 Mon Sep 17 00:00:00 2001 From: Tal Usvyatsky Date: Fri, 21 Aug 2026 10:23:31 -0400 Subject: [PATCH 2/2] test: add regression test for multiple state machines with pre-existing log groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Covers #666 — addStateMachines() previously threw a construct-id collision when called for a second state machine with a pre-defined log group, because the log group lookup was scoped to the shared DatadogStepFunctions construct instead of the state machine. Co-Authored-By: Claude Sonnet 5 --- test/datadog-step-functions.spec.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/datadog-step-functions.spec.ts b/test/datadog-step-functions.spec.ts index cb07bfc8..aca40d15 100644 --- a/test/datadog-step-functions.spec.ts +++ b/test/datadog-step-functions.spec.ts @@ -42,6 +42,32 @@ describe("DatadogStepFunctions", () => { expect(logConfig.destinations).toHaveLength(1); }); + it("supports multiple state machines with pre-existing, distinct log groups", () => { + const stack = new Stack(); + const stateMachineOne = new sfn.StateMachine(stack, "StateMachineOne", { + definitionBody: sfn.DefinitionBody.fromChainable(new sfn.Pass(stack, "PassStateOne")), + logs: { + destination: new logs.LogGroup(stack, "LogGroupOne"), + level: sfn.LogLevel.ERROR, + includeExecutionData: false, + }, + }); + const stateMachineTwo = new sfn.StateMachine(stack, "StateMachineTwo", { + definitionBody: sfn.DefinitionBody.fromChainable(new sfn.Pass(stack, "PassStateTwo")), + logs: { + destination: new logs.LogGroup(stack, "LogGroupTwo"), + level: sfn.LogLevel.ERROR, + includeExecutionData: false, + }, + }); + + const datadogSfn = new DatadogStepFunctions(stack, "DatadogStepFunctions", {}); + expect(() => { + datadogSfn.addStateMachines([stateMachineOne]); + datadogSfn.addStateMachines([stateMachineTwo]); + }).not.toThrow(); + }); + it("throws if loggingConfiguration is an unresolved token", () => { const stack = new Stack(); const stateMachine = new sfn.StateMachine(stack, "StateMachine", {