Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

kohidave
Copy link

@kohidave kohidave commented Jul 4, 2019

UpdateContainerInstanceState and ListTask APIs require permissions on
a container-instance resource, rather than a cluster resource. This
change updates the policy to:

  1. remove the cluster as the resource restriction
  2. add the cluster as a resource condition

More info on ECS Resource-Level permissions can be found here:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-supported-iam-actions-resources.html

Fixes #3190


Please read the contribution guidelines and follow the pull-request checklist.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

UpdateContainerInstanceState and ListTask APIs require permissions on
a container-instance resource, rather than a cluster resource. This
change updates the policy to:

1. remove the cluster as the resource restriction
2. add the cluster as a resource condition

More info on ECS Resource-Level permissions can be found here:
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-supported-iam-actions-resources.html

Fixes aws#3190
@kohidave kohidave requested review from SoManyHs and a team as code owners July 4, 2019 01:49
@ghost ghost requested a review from rix0rrr July 4, 2019 01:49
@kohidave
Copy link
Author

kohidave commented Jul 4, 2019

Good buddy @pkandasamy91 - mind taking a look? :)

Copy link
Contributor

@piradeepk piradeepk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! @rix0rrr @eladb please review

@eladb
Copy link
Contributor

eladb commented Jul 4, 2019

@kohidave welcome!

Was this closed intentionally?

@piradeepk
Copy link
Contributor

@eladb the build was failing so i pulled it in and updated it #3199

],
resources: [props.cluster.clusterArn]
}));

// Restrict to the container-instance operations to the ECS Cluster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Restrict to the container-instance operations to the ECS cluster"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

conditions: {
ArnEquals: {'ecs:cluster': props.cluster.clusterArn}
},
resources: ['*']
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ECS drain hook can't change instance state to draining
3 participants