Skip to content

Commit 3d44c3d

Browse files
committed
Added glue permissions mirroring console behavior.
1 parent 8e6f8a5 commit 3d44c3d

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lib/deploy/stepFunctions/compileIamRole.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ function getBatchPermissions() {
9191
}];
9292
}
9393

94+
function getGluePermissions() {
95+
return [{
96+
action: 'glue:StartJobRun,glue:GetJobRun,glue:GetJobRuns,glue:BatchStopJobRun',
97+
resource: '*',
98+
}];
99+
}
100+
94101
function getEcsPermissions() {
95102
return [{
96103
action: 'ecs:RunTask,ecs:StopTask,ecs:DescribeTasks',
@@ -181,6 +188,10 @@ function getIamPermissions(serverless, taskStates) {
181188
case 'arn:aws:states:::batch:submitJob':
182189
return getBatchPermissions();
183190

191+
case 'arn:aws:states:::glue:startJobRun.sync':
192+
case 'arn:aws:states:::glue:startJobRun':
193+
return getGluePermissions();
194+
184195
case 'arn:aws:states:::ecs:runTask.sync':
185196
case 'arn:aws:states:::ecs:runTask':
186197
return getEcsPermissions();

lib/deploy/stepFunctions/compileIamRole.test.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,46 @@ describe('#compileIamRole', () => {
590590
}]);
591591
});
592592

593+
it('should give glue permissions (too permissive, but mirrors console behaviour)', () => {
594+
const genStateMachine = (name) => ({
595+
name,
596+
definition: {
597+
StartAt: 'A',
598+
States: {
599+
A: {
600+
Type: 'Task',
601+
Resource: 'arn:aws:states:::glue:startJobRun',
602+
Next: 'B',
603+
},
604+
B: {
605+
Type: 'Task',
606+
Resource: 'arn:aws:states:::glue:startJobRun.sync',
607+
End: true,
608+
},
609+
},
610+
},
611+
});
612+
613+
serverless.service.stepFunctions = {
614+
stateMachines: {
615+
myStateMachine1: genStateMachine('stateMachineBeta1'),
616+
myStateMachine2: genStateMachine('stateMachineBeta2'),
617+
},
618+
};
619+
620+
serverlessStepFunctions.compileIamRole();
621+
const statements = serverlessStepFunctions.serverless.service
622+
.provider.compiledCloudFormationTemplate.Resources.IamRoleStateMachineExecution
623+
.Properties.Policies[0].PolicyDocument.Statement;
624+
625+
const gluePermissions = statements.filter(s =>
626+
_.isEqual(s.Action,
627+
['glue:StartJobRun', 'glue:GetJobRun', 'glue:GetJobRuns', 'glue:BatchStopJobRun'])
628+
);
629+
expect(gluePermissions).to.have.lengthOf(1);
630+
expect(gluePermissions[0].Resource).to.equal('*');
631+
});
632+
593633
it('should give ECS permissions (too permissive, but mirrors console behaviour)', () => {
594634
const genStateMachine = (name) => ({
595635
name,

0 commit comments

Comments
 (0)