Skip to content

Commit 115ddf6

Browse files
renanwilliamclaude
authored andcommitted
fix: add missing ecs:TagResource permission for ECS tasks (serverless-operations#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 serverless-operations#656 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1be8227 commit 115ddf6

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
@@ -194,7 +194,7 @@ function getGluePermissions() {
194194

195195
function getEcsPermissions() {
196196
return [{
197-
action: 'ecs:RunTask,ecs:StopTask,ecs:DescribeTasks,iam:PassRole',
197+
action: 'ecs:RunTask,ecs:StopTask,ecs:DescribeTasks,ecs:TagResource,iam:PassRole',
198198
resource: '*',
199199
}, {
200200
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)