Skip to content

Commit dffb7ae

Browse files
authored
Merge pull request #322 from deconltd/master
Allow logging to standard workflow
2 parents 0724ad1 + be44120 commit dffb7ae

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

lib/deploy/stepFunctions/compileIamRole.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ module.exports = {
384384
const taskStates = getTaskStates(stateMachineObj.definition.States);
385385
let iamPermissions = getIamPermissions.bind(this)(taskStates);
386386

387-
if (stateMachineObj.type === 'EXPRESS') {
387+
if (stateMachineObj.loggingConfig) {
388388
iamPermissions.push({
389389
action: 'logs:CreateLogDelivery,logs:GetLogDelivery,logs:UpdateLogDelivery,logs:DeleteLogDelivery,logs:ListLogDeliveries,logs:PutResourcePolicy,logs:DescribeResourcePolicies,logs:DescribeLogGroups',
390390
resource: '*',

lib/deploy/stepFunctions/compileIamRole.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,12 +1786,11 @@ describe('#compileIamRole', () => {
17861786
expect(lambdaPermissions[0].Resource).to.deep.equal(lambdaArns);
17871787
});
17881788

1789-
it('should give CloudWatch Logs permissions for Express Workflow', () => {
1789+
it('should give CloudWatch Logs permissions', () => {
17901790
serverless.service.stepFunctions = {
17911791
stateMachines: {
17921792
myStateMachine1: {
17931793
id: 'StateMachine1',
1794-
type: 'EXPRESS',
17951794
loggingConfig: {
17961795
destinations: [
17971796
{

lib/deploy/stepFunctions/compileStateMachines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ module.exports = {
188188
_.forEach(stateMachineTags, tag => Tags.push(tag));
189189
}
190190

191-
if (value.type === 'EXPRESS' && value.loggingConfig) {
191+
if (value.loggingConfig) {
192192
const Destinations = (value.loggingConfig.destinations || [])
193193
.map(arn => ({
194194
CloudWatchLogsLogGroup: {

lib/deploy/stepFunctions/compileStateMachines.test.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,12 +1307,44 @@ describe('#compileStateMachines', () => {
13071307
expect(definitionString).to.not.contain('#{AWS::AccountId}');
13081308
});
13091309

1310-
it('should compile logging configuration for Express Workflows', () => {
1310+
it('should compile Express Workflow', () => {
13111311
serverless.service.stepFunctions = {
13121312
stateMachines: {
13131313
myStateMachine1: {
13141314
name: 'stateMachineBeta1',
13151315
type: 'EXPRESS',
1316+
definition: {
1317+
StartAt: 'A',
1318+
States: {
1319+
A: {
1320+
Type: 'Task',
1321+
Resource: 'arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:hello',
1322+
End: true,
1323+
},
1324+
},
1325+
},
1326+
},
1327+
},
1328+
};
1329+
1330+
serverlessStepFunctions.compileStateMachines();
1331+
const actual = serverlessStepFunctions
1332+
.serverless
1333+
.service
1334+
.provider
1335+
.compiledCloudFormationTemplate
1336+
.Resources
1337+
.StateMachineBeta1
1338+
.Properties;
1339+
1340+
expect(actual.StateMachineType).to.equal('EXPRESS');
1341+
});
1342+
1343+
it('should compile logging configuration', () => {
1344+
serverless.service.stepFunctions = {
1345+
stateMachines: {
1346+
myStateMachine1: {
1347+
name: 'stateMachineBeta1',
13161348
loggingConfig: {
13171349
destinations: [
13181350
{
@@ -1344,7 +1376,6 @@ describe('#compileStateMachines', () => {
13441376
.StateMachineBeta1
13451377
.Properties;
13461378

1347-
expect(actual.StateMachineType).to.equal('EXPRESS');
13481379
expect(actual).to.haveOwnProperty('LoggingConfiguration');
13491380
expect(actual.LoggingConfiguration.Level).to.equal('OFF'); // default value
13501381
expect(actual.LoggingConfiguration.IncludeExecutionData).to.equal(false); // default value

0 commit comments

Comments
 (0)