From 5a6644cfdda9fe555a4e144d97597a5ec7823294 Mon Sep 17 00:00:00 2001 From: deconltd <53143167+deconltd@users.noreply.github.com> Date: Sun, 15 Mar 2020 11:45:10 +0200 Subject: [PATCH 1/3] Allow logging to standard workflow --- lib/deploy/stepFunctions/compileStateMachines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/deploy/stepFunctions/compileStateMachines.js b/lib/deploy/stepFunctions/compileStateMachines.js index 0e148d15..3b538765 100644 --- a/lib/deploy/stepFunctions/compileStateMachines.js +++ b/lib/deploy/stepFunctions/compileStateMachines.js @@ -188,7 +188,7 @@ module.exports = { _.forEach(stateMachineTags, tag => Tags.push(tag)); } - if (value.type === 'EXPRESS' && value.loggingConfig) { + if (value.loggingConfig) { const Destinations = (value.loggingConfig.destinations || []) .map(arn => ({ CloudWatchLogsLogGroup: { From bbeae3c0fc7d8ddf9976097d1f08c2b8aba95c0c Mon Sep 17 00:00:00 2001 From: deconltd <53143167+deconltd@users.noreply.github.com> Date: Sun, 15 Mar 2020 11:46:34 +0200 Subject: [PATCH 2/3] Allow logging to standard workflow --- lib/deploy/stepFunctions/compileIamRole.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/deploy/stepFunctions/compileIamRole.js b/lib/deploy/stepFunctions/compileIamRole.js index e3f39dd3..8c5b1325 100644 --- a/lib/deploy/stepFunctions/compileIamRole.js +++ b/lib/deploy/stepFunctions/compileIamRole.js @@ -384,7 +384,7 @@ module.exports = { const taskStates = getTaskStates(stateMachineObj.definition.States); let iamPermissions = getIamPermissions.bind(this)(taskStates); - if (stateMachineObj.type === 'EXPRESS') { + if (stateMachineObj.loggingConfig) { iamPermissions.push({ action: 'logs:CreateLogDelivery,logs:GetLogDelivery,logs:UpdateLogDelivery,logs:DeleteLogDelivery,logs:ListLogDeliveries,logs:PutResourcePolicy,logs:DescribeResourcePolicies,logs:DescribeLogGroups', resource: '*', From be44120631159e67b97c87161acbb51fe8f01b86 Mon Sep 17 00:00:00 2001 From: Shay Hananashvili Date: Sun, 15 Mar 2020 15:19:59 +0200 Subject: [PATCH 3/3] logging configurations tests --- .../stepFunctions/compileIamRole.test.js | 3 +- .../compileStateMachines.test.js | 35 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/lib/deploy/stepFunctions/compileIamRole.test.js b/lib/deploy/stepFunctions/compileIamRole.test.js index 5cf4dd8e..61cfc8d7 100644 --- a/lib/deploy/stepFunctions/compileIamRole.test.js +++ b/lib/deploy/stepFunctions/compileIamRole.test.js @@ -1786,12 +1786,11 @@ describe('#compileIamRole', () => { expect(lambdaPermissions[0].Resource).to.deep.equal(lambdaArns); }); - it('should give CloudWatch Logs permissions for Express Workflow', () => { + it('should give CloudWatch Logs permissions', () => { serverless.service.stepFunctions = { stateMachines: { myStateMachine1: { id: 'StateMachine1', - type: 'EXPRESS', loggingConfig: { destinations: [ { diff --git a/lib/deploy/stepFunctions/compileStateMachines.test.js b/lib/deploy/stepFunctions/compileStateMachines.test.js index 5e3d073d..846d47f6 100644 --- a/lib/deploy/stepFunctions/compileStateMachines.test.js +++ b/lib/deploy/stepFunctions/compileStateMachines.test.js @@ -1307,12 +1307,44 @@ describe('#compileStateMachines', () => { expect(definitionString).to.not.contain('#{AWS::AccountId}'); }); - it('should compile logging configuration for Express Workflows', () => { + it('should compile Express Workflow', () => { serverless.service.stepFunctions = { stateMachines: { myStateMachine1: { name: 'stateMachineBeta1', type: 'EXPRESS', + definition: { + StartAt: 'A', + States: { + A: { + Type: 'Task', + Resource: 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:hello', + End: true, + }, + }, + }, + }, + }, + }; + + serverlessStepFunctions.compileStateMachines(); + const actual = serverlessStepFunctions + .serverless + .service + .provider + .compiledCloudFormationTemplate + .Resources + .StateMachineBeta1 + .Properties; + + expect(actual.StateMachineType).to.equal('EXPRESS'); + }); + + it('should compile logging configuration', () => { + serverless.service.stepFunctions = { + stateMachines: { + myStateMachine1: { + name: 'stateMachineBeta1', loggingConfig: { destinations: [ { @@ -1344,7 +1376,6 @@ describe('#compileStateMachines', () => { .StateMachineBeta1 .Properties; - expect(actual.StateMachineType).to.equal('EXPRESS'); expect(actual).to.haveOwnProperty('LoggingConfiguration'); expect(actual.LoggingConfiguration.Level).to.equal('OFF'); // default value expect(actual.LoggingConfiguration.IncludeExecutionData).to.equal(false); // default value