How to propogate tags to an ECS Task launched from an EventBridge Target?

1.8k Views Asked by At

I have a EventBridge (previously CloudWatch Events) Rule and Target that are used to launch ECS Tasks on a schedule (cron). I would like to apply some tags to the Task.

I tried including tags in RegisterTaskDefinition, but this did not result in any tags being set on the Tasks, as RunTask does not propagate tags if propagateTags is unspecified.

PutTargets is the action to create the event target that will eventually call RunTask. I searched in ecsParameters (EcsParameters) and input (TaskOverride) for fields that would correspond to either tags or propagateTags from RunTask but I could not find any corresponding fields.

Is there any way to apply tags to an ECS Task that is run from an EventBridge rule target?

2021-06-24 update (thanks @baxang): EventBridge has added ecsParameters.PropagateTags: "TASK_DEFINITION" to the API documentation and to some SDKs yesterday (containers-roadmap#89)!

1

There are 1 best solutions below

0
On BEST ANSWER

It seems the API has propagateTags https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_EcsParameters.html#eventbridge-Type-EcsParameters-PropagateTags so if you are launching the task via API, there seems to be a way.

CloudFormation however does not support the property: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-ecsparameters.html. This issue(link) on aws-cloudformation/cloudformation-coverage-roadmap repo seems to be related.