【发布时间】:2020-06-06 21:58:27
【问题描述】:
我使用 Cloudformation 模板创建了我的 ECS、服务和任务,其中未使用 enableECSManagedTags 或传播标签。
创建堆栈后,我试图在下面运行以添加标签
service_tag_response = self.ecs_client.tag_resource(resourceArn=self.service_arn_name,
tags=self.service_tag)
然后我得到了错误,when calling the TagResource operation: Long arn format must be used for tagging operations
然后我尝试启用 longresource 选项,我的脚本如下所示
response = self.ecs_client.put_account_setting(name='serviceLongArnFormat', value='enabled')
if 'ResponseMetadata' in response and \
response['ResponseMetadata']['HTTPStatusCode'] == 200:
service_tag_response = self.ecs_client.tag_resource(resourceArn=self.service_arn_name,
tags=self.service_tag)
然后我也遇到了同样的错误。
有谁知道,如何解决这个错误?
我的服务是:arn:aws:ecs:eu-west-1:12345678901:service/my-service
【问题讨论】:
-
什么是
service_arn_name?似乎是它的唯一名称,而不是完整的 arn。 -
我的服务 arn 是
arn:aws:ecs:eu-west-1:12345678901:service/my-service,所以您建议只使用my-service就足够了。让我试试。同样令人困惑的是,在 boto3 手册中,他们建议服务的 arm 并且在 aws 领域 arn 以arn开头 -
错误信息显示:“Long arn format must 用于标记操作”。这表明您必须使用完整的 arn,而不是服务名称。
-
根据docs.aws.amazon.com/AmazonECS/latest/userguide/…,我也使用过
arn:aws:ecs:eu-west-1:12345678901:service/mycluster/my-service,然后它抱怨when calling the TagResource operation: The specified service does not have the longArn format. Only services created after opting in will have the new format。我在脚本中使用了 arn 名称,那么使用Long arn format是什么意思? -
标签资源中的 arn 示例为 here。也许这会让你知道出了什么问题。
标签: boto3 amazon-ecs