-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ecs): grant drain-hook policy container-instance permissions #3196
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,11 +97,21 @@ export class InstanceDrainHook extends cdk.Construct { | |
actions: [ | ||
'ecs:ListContainerInstances', | ||
'ecs:SubmitContainerStateChange', | ||
'ecs:SubmitTaskStateChange', | ||
'ecs:UpdateContainerInstancesState', | ||
'ecs:ListTasks' | ||
'ecs:SubmitTaskStateChange' | ||
], | ||
resources: [props.cluster.clusterArn] | ||
})); | ||
|
||
// Restrict to the container-instance operations to the ECS Cluster | ||
fn.addToRolePolicy(new iam.PolicyStatement({ | ||
actions: [ | ||
'ecs:UpdateContainerInstancesState', | ||
'ecs:ListTasks' | ||
], | ||
conditions: { | ||
ArnEquals: {'ecs:cluster': props.cluster.clusterArn} | ||
}, | ||
resources: ['*'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just making sure: does it make sense to use "*" here and not a specific resource? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does because otherwise, the resource would need to be the container instance id, but it doesn't make sense in the case of instances that are scaled up or down, as instance ids can change frequently. As per https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-supported-iam-actions-resources.html, we used the ecs:cluster condition key instead. |
||
})); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Restrict
tothe container-instance operations to the ECS cluster"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed