Skip to content

Commit 1e7b2f1

Browse files
renanwilliamclaude
andauthored
fix: add missing ecs:TagResource permission for ECS tasks (#657)
When using serverless-step-functions to deploy ECS tasks with tags, the auto-generated IAM policies were missing the ecs:TagResource permission. This caused Step Functions executions to fail with an AccessDeniedException when attempting to tag ECS tasks. This commit adds the ecs:TagResource permission to the getEcsPermissions function, allowing ECS tasks to be properly tagged during execution. Fixes #656 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent b4630f1 commit 1e7b2f1

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/deploy/stepFunctions/compileIamRole.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function getGluePermissions() {
176176

177177
function getEcsPermissions() {
178178
return [{
179-
action: 'ecs:RunTask,ecs:StopTask,ecs:DescribeTasks,iam:PassRole',
179+
action: 'ecs:RunTask,ecs:StopTask,ecs:DescribeTasks,ecs:TagResource,iam:PassRole',
180180
resource: '*',
181181
}, {
182182
action: 'events:PutTargets,events:PutRule,events:DescribeRule',

lib/deploy/stepFunctions/compileIamRole.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ describe('#compileIamRole', () => {
16511651
.provider.compiledCloudFormationTemplate.Resources.StateMachine1Role
16521652
.Properties.Policies[0].PolicyDocument.Statement;
16531653

1654-
const ecsPermissions = statements.filter(s => _.isEqual(s.Action, ['ecs:RunTask', 'ecs:StopTask', 'ecs:DescribeTasks', 'iam:PassRole']));
1654+
const ecsPermissions = statements.filter(s => _.isEqual(s.Action, ['ecs:RunTask', 'ecs:StopTask', 'ecs:DescribeTasks', 'ecs:TagResource', 'iam:PassRole']));
16551655
expect(ecsPermissions).to.have.lengthOf(1);
16561656
expect(ecsPermissions[0].Resource).to.equal('*');
16571657

@@ -2694,7 +2694,7 @@ describe('#compileIamRole', () => {
26942694
const expectation = (policy, lambdaArns, sns, sqsArn) => {
26952695
const statements = policy.PolicyDocument.Statement;
26962696

2697-
const ecsPermissions = statements.filter(s => _.isEqual(s.Action, ['ecs:RunTask', 'ecs:StopTask', 'ecs:DescribeTasks', 'iam:PassRole']));
2697+
const ecsPermissions = statements.filter(s => _.isEqual(s.Action, ['ecs:RunTask', 'ecs:StopTask', 'ecs:DescribeTasks', 'ecs:TagResource', 'iam:PassRole']));
26982698
expect(ecsPermissions).to.have.lengthOf(1);
26992699
expect(ecsPermissions[0].Resource).to.equal('*');
27002700

0 commit comments

Comments
 (0)