Skip to content
Open
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
19 changes: 11 additions & 8 deletions lib/deploy/stepFunctions/compileIamRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function sqsQueueUrlToArn(serverless, queueUrl) {

function getSqsPermissions(serverless, state) {
if (_.has(state, 'Parameters.QueueUrl')
|| _.has(state, ['Parameters', 'QueueUrl.$'])) {
|| _.has(state, ['Parameters', 'QueueUrl.$'])) {
// if queue URL is provided by input, then need pervasive permissions (i.e. '*')
const queueArn = state.Parameters['QueueUrl.$']
? '*'
Expand All @@ -85,7 +85,7 @@ function getSqsPermissions(serverless, state) {

function getSnsPermissions(serverless, state) {
if (_.has(state, 'Parameters.TopicArn')
|| _.has(state, ['Parameters', 'TopicArn.$'])) {
|| _.has(state, ['Parameters', 'TopicArn.$'])) {
// if topic ARN is provided by input, then need pervasive permissions
const topicArn = state.Parameters['TopicArn.$'] ? '*' : state.Parameters.TopicArn;
return [{ action: 'sns:Publish', resource: topicArn }];
Expand Down Expand Up @@ -561,24 +561,25 @@ function getEventBridgePermissions(state) {
];
}

function getEventBridgeSchedulerPermissions(state) {
const scheduleGroupName = state.Parameters.GroupName;
function getEventBridgeSchedulerPermissions(action, state) {
const scheduleGroupName = state.Parameters.GroupName || 'default';
const scheduleTargetRoleArn = state.Parameters.Target.RoleArn;

return [
{
action: 'scheduler:CreateSchedule',
action,
resource: {
'Fn::Sub': [
'arn:${AWS::Partition}:scheduler:${AWS::Region}:${AWS::AccountId}:schedule/${scheduleGroupName}/*',
{ scheduleGroupName },
],
},
},
{
// create schedule needs a target role arn
...(action === 'scheduler:CreateSchedule' ? [{
action: 'iam:PassRole',
resource: scheduleTargetRoleArn,
},
}] : []),
];
}

Expand Down Expand Up @@ -748,7 +749,9 @@ function getIamPermissions(taskStates) {
return getEventBridgePermissions(state);

case 'arn:aws:states:::aws-sdk:scheduler:createSchedule':
return getEventBridgeSchedulerPermissions(state);
return getEventBridgeSchedulerPermissions('scheduler:CreateSchedule', state);
case 'arn:aws:states:::aws-sdk:scheduler:deleteSchedule':
return getEventBridgeSchedulerPermissions('scheduler:DeleteSchedule', state);

case 'arn:aws:states:::s3:getObject':
case 'arn:aws:states:::aws-sdk:s3:getObject':
Expand Down
Loading