如何将标签传播到从 EventBridge 目标启动的 ECS 任务?

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

我有一个 EventBridge(以前称为 CloudWatch Events)Rule and Target that are used to launch ECS Tasks on a schedule (cron)。我想为任务应用一些标签。

我试过在 RegisterTaskDefinition, but this did not result in any tags being set on the Tasks, as RunTask does not propagate tags if propagateTags 中包含标签未指定。

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 但我找不到任何对应的字段。

有什么方法可以将标签应用到来自 EventBridge 规则目标的 运行 的 ECS 任务?

2021-06-24 更新(感谢@baxang):EventBridge 已将 ecsParameters.PropagateTags: "TASK_DEFINITION" 添加到 API 文档和一些 SDK 昨天(containers-roadmap#89)!

似乎 API 有 propagateTags https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_EcsParameters.html#eventbridge-Type-EcsParameters-PropagateTags 所以如果你通过 API 启动任务,似乎有办法。

但是 CloudFormation 不支持 属性:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-events-rule-ecsparameters.html. This issue(link) on aws-cloudformation/cloudformation-coverage-roadmap 回购似乎是相关的。