Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/datadog-step-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions test/datadog-step-functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
Loading