-
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
Have a question? Please checkout our Slack Community or visit our Slack Archive.
Describe the Feature
Support principal conditions for allowed ECS services
Expected Behavior
Update this section of code to allow a dynamic set of conditionals to further restrict the allowed services.
dynamic "principals" {
for_each = length(var.allowed_aws_services_for_sns_published) > 0 ? ["_enable"] : []
content {
type = "Service"
identifiers = var.allowed_aws_services_for_sns_published
}
}
Use Case
Allow ecs.amazonaws.com
and a specific ECS task role to limit access.
Example expected policy:
{
"Sid": "Grant my-service permission to publish to the topic.",
"Effect": "Allow",
"Principal": {
"Service": "ecs.amazonaws.com"
},
"Action": "SNS:Publish",
"Resource": "arn:aws:sns:us-east-1:1234567890:sns-topic",
"Condition": {
"ArnEquals": {
"aws:SourceArn": "arn:aws:iam::1234567890:role/my-service-ecsTaskRole-6L1TOAC7MPTEC"
}
}
},
Describe Ideal Solution
Since the allowed_aws_services_for_sns_published
is just a list, it will be a breaking change, but we could update that to be a map which could enable more values for the list.
Current (in an Atmos stack):
allowed_aws_services_for_sns_published:
- ecs.amazonaws.com
Proposed:
allowed_aws_services_for_sns_published:
- service: ecs.amazonaws.com
conditional:
ArnEquals:
"aws:SourceArn": arn:aws:iam::1234567890:role/my-service-ecsTaskRole-6L1TOAC7MPTEC
Alternatives Considered
- Keep the current list and add a new variable for conditionals to be zipmapped internally. This limits it to more of a global option and mixing services becomes more problematic, but it supports backwards compat.
allowed_aws_services_for_sns_published:
- ecs.amazonaws.com
- otherservice.amazonaws.com
allowed_aws_services_for_sns_published_conditionals:
- service: ecs.amazonaws.com
conditionals:
- ArnEquals: "aws:SourceArn": arn:aws:iam::1234567890:role/my-service-ecsTaskRole-6L1TOAC7MPTEC
- ArnEquals: "aws:SourceArn": arn:aws:iam::1234567890:role/other-service-ecsTaskRole-6L1TOAC7MPTEC
- ArnEquals: "aws:SourceArn": arn:aws:iam::1234567890:role/some-app-ecsTaskRole-6L1TOAC7MPTEC
- service: otherservice.amazonaws.com
conditionals:
- ArnEquals: "aws:SourceArn": arn:aws:iam::1234567890:role/something-else
This would be zipmapped to combine the service with the conditionals.
Additional Context
Metadata
Metadata
Assignees
Labels
No labels