Repository navigation
fix(ecs): honor task-set resource tags in IAM - #9086
Conversation
PR Summary by QodoHonor ECS task-set tags in IAM resource-tag conditions
AI Description
Merge Risk
|
Code Review by Qodo
1. Task sets cannot be retagged after creation
|
| case "task-set" -> Optional.ofNullable(taskSets.get(arn)) | ||
| .filter(ts -> arn.equals(ts.getTaskSetArn())).map(TaskSet::getTags); |
There was a problem hiding this comment.
1. Task sets cannot be retagged after creation 🐞 Bug ≡ Correctness
The new storedTags branch reads task-set tags, but the sibling findByArn lookup and tag-resource switches still omit TaskSet. Calling TagResource, UntagResource or ListTagsForResource with a task-set ARN therefore returns a resource-not-found error, leaving tag-based policies tied to creation-time values.
Agent Prompt
## Issue description
The new task-set tag reader has no matching task-set support in the ECS tag APIs, so tags cannot be changed or listed after creation.
## Fix Focus Areas
- src/main/java/io/floci/aws/services/ecs/EcsService.java[3764-3787]
- src/main/java/io/floci/aws/services/ecs/EcsService.java[3796-3840]
- src/test/java/io/floci/aws/services/iam/IamRequestResourceEnforcementIntegrationTest.java[835-860]
## Recommended Fix
Recognize task-set ARNs in `findByArn` and handle `TaskSet` in the tag getter and setter switches. Add a test that retags a task set through the ECS tag API and checks the resulting IAM resource-tag decision.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Thanks for flagging this. I checked the operation-specific ECS references and the pinned botocore 1.43.118 model. TagResource and UntagResource list capacity providers, tasks, services, task definitions, clusters, and container instances; ListTagsForResource also omits task sets, while CreateTaskSet accepts tags. The Service Authorization Reference currently lists task-set for the tagging actions, so AWS's references conflict. I kept #9086 scoped to the creation-time tags used by DeleteTaskSet's aws:ResourceTag condition instead of adding runtime retag/list/untag behavior the operation references do not list.
The focused JDK 25 task-set IAM regression passed 1/1 on this head. I did not run the full suite or live AWS. Current-head CI is 26 passed and 2 skipped; human review is still required.
|
On Qodo finding 2 in the summary above, I added a full-ARN DeleteTaskSet regression in 7b409f8. With a broad Allow and an aws:ResourceTag/team=data explicit Deny, deletion of the tagged task set by full ARN is denied; a differently tagged task set can still be deleted by full ARN under the same policy. RequestResources.fill retains the caller's exact ARN before rendering the generated resource pattern, so the tag lookup sees the stored tags. I did not change the production IAM mapping. The focused JDK 25 test passed (1/1) and Checkstyle passed. I have not exercised UpdateTaskSet through its public handler or run live AWS. The new head is Verified; CI is still running and human review is pending. |
|
The new head is blocked by shard 4: SmtpRelayTest.relayRaw_nestingThatParsesButOverflowsTheWriter_isSkippedNotThrown gets a null parsed MIME message before the relay runs. This revision only adds the task-set IAM regression; shard 4 passed on the previous head. The failing SES method passes locally on JDK 25, both alone (1/1) and with its full class (52/52). The test uses a fixed 10,000-layer MIME depth, so the parser/writer boundary appears stack-sensitive across JVMs. Could a maintainer rerun the failed job? CI on this head is still red, and human review is pending. |
pgermosen
left a comment
There was a problem hiding this comment.
@JimmyLiuJia thanks, storedTags now answers a task-set ARN with the tags the task set was created with, so an aws:ResourceTag condition on DeleteTaskSet reads them, and the test shows the team=data set deleted and the team=web one refused.
The full-ARN case you added covers the other way in: a task set named by its ARN still has its tags looked up, so the team=data Deny holds and the team=web set can still be deleted.
Summary
Resolve ECS task-set tags from the complete task-set ARN during IAM resource-tag evaluation. Closes #8818.
Type of change
fix:)feat:)feat!:orfix!:)AWS Compatibility
CreateTaskSetaccepts tags, andDeleteTaskSetis authorized against the named task set. The regression exercises the AWS JSON 1.1 request path and confirms thataws:ResourceTag/team=datapermits deletion of that task set while denying deletion of a task set taggedteam=web.Checklist
./mvnw testpasses locally (focused IAM integration tests passed; the full suite was not run)New integration test added
Commit message follows Conventional Commits
No more than 2 open, non-draft pull requests and no more than 4 open pull requests total in this repository
Controller return types remain reflection-safe