Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added missing support for IAM PassRole of tasks that create Even… #607

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
5 changes: 5 additions & 0 deletions lib/deploy/stepFunctions/compileIamRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ function getEventBridgePermissions(state) {

function getEventBridgeSchedulerPermissions(state) {
const scheduleGroupName = state.Parameters.GroupName;
const scheduleTargetRoleArn = state.Parameters.Target.RoleArn;

return [
{
Expand All @@ -574,6 +575,10 @@ function getEventBridgeSchedulerPermissions(state) {
],
},
},
{
action: 'iam:PassRole',
resource: scheduleTargetRoleArn,
},
];
}

Expand Down
11 changes: 7 additions & 4 deletions lib/deploy/stepFunctions/compileIamRole.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3722,7 +3722,7 @@ describe('#compileIamRole', () => {
]);
});

it('should give event bridge scheduler createSchedule permissions', () => {
it('should give event bridge scheduler createSchedule and passRole permissions', () => {
const genStateMachine = id => ({
id,
definition: {
Expand Down Expand Up @@ -3765,14 +3765,17 @@ describe('#compileIamRole', () => {
.provider.compiledCloudFormationTemplate.Resources.StateMachine1Role
.Properties.Policies[0].PolicyDocument.Statement;

const eventPermissions = statements.filter(s => _.isEqual(s.Action, ['scheduler:CreateSchedule']));
expect(eventPermissions[0].Resource).to.has.lengthOf(1);
expect(eventPermissions[0].Resource).to.deep.eq([{
const schedulerPermissions = statements.filter(s => _.isEqual(s.Action, ['scheduler:CreateSchedule']));
expect(schedulerPermissions[0].Resource).to.has.lengthOf(1);
expect(schedulerPermissions[0].Resource).to.deep.eq([{
'Fn::Sub': [
'arn:${AWS::Partition}:scheduler:${AWS::Region}:${AWS::AccountId}:schedule/${scheduleGroupName}/*',
{ scheduleGroupName: 'MyScheduleGroup' },
],
}]);
const rolePermissions = statements.filter(s => _.isEqual(s.Action, ['iam:PassRole']));
expect(rolePermissions[0].Resource).to.has.lengthOf(1);
expect(rolePermissions[0].Resource).to.deep.eq(['arn:aws:iam::${AWS::AccountId}:role/MyIAMRole']);
});

it('should handle permissionsBoundary', () => {
Expand Down
Loading