Describe the feature
Allow passing a IAM Role to ScheduledFargateTask which in turn is passed as the role argument to EcsTask.
Use Case
The default IAM role created in EcsTask gets a policy for ecs:RunTask with the full task definition arn as the resource, that is with its revision. I want to be able to set a ecs:RunTask policy with a wild card as the task definition revision component, i.e instead of:
PolicyStatement(
actions=["ecs:RunTask"],
resource=["arn:aws:ecs:XX:XX:task-definition/some-task-definition:42"],
...
)
I want:
PolicyStatement(
actions=["ecs:RunTask"],
resource=["arn:aws:ecs:XX:XX:task-definition/some-task-definition:*"],
...
)
See:
|
const policyStatements = [new iam.PolicyStatement({ |
|
actions: ['ecs:RunTask'], |
|
resources: [this.taskDefinition.taskDefinitionArn], |
|
conditions: { |
|
ArnEquals: { 'ecs:cluster': this.cluster.clusterArn }, |
|
}, |
|
})]; |
Proposed Solution
My proposal is to leverage the already existing role argument on EcsTask by simply adding the same argument to ScheduledFargateTask and passing it on through.
Other Information
No response
Acknowledgements
CDK version used
2.44
Environment details (OS name and version, etc.)
MacOS 12.6.1
Describe the feature
Allow passing a IAM Role to
ScheduledFargateTaskwhich in turn is passed as theroleargument toEcsTask.Use Case
The default IAM role created in
EcsTaskgets a policy forecs:RunTaskwith the full task definition arn as the resource, that is with its revision. I want to be able to set aecs:RunTaskpolicy with a wild card as the task definition revision component, i.e instead of:I want:
See:
aws-cdk/packages/@aws-cdk/aws-events-targets/lib/ecs-task.ts
Lines 198 to 204 in 66d1ed3
Proposed Solution
My proposal is to leverage the already existing
roleargument onEcsTaskby simply adding the same argument toScheduledFargateTaskand passing it on through.Other Information
No response
Acknowledgements
CDK version used
2.44
Environment details (OS name and version, etc.)
MacOS 12.6.1