亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 AWS ECS 集群獲取標簽返回空列表

從 AWS ECS 集群獲取標簽返回空列表

開滿天機 2023-05-17 16:44:29
我需要從我的 ECS 集群中讀取標簽。我通過describeClusters()調用成功列出了我的所有集群。然后我進行了getTags()調用,但它錯誤地返回了一個空列表。    List<Cluster> clusters = clusterDescriptionResult.getClusters();    for (Cluster cluster : clusters) {        String clusterArn = cluster.getClusterArn();        //System.out.println("Cluster: " + clusterArn);        List<Tag> tagList = cluster.getTags();我想我一定是做錯了什么,所以作為測試,我用 Python 重寫了代碼。    clusterList = ecsClient.list_clusters()    for clusterArn in clusterList["clusterArns"]:        tagListData = ecsClient.list_tags_for_resource(resourceArn=clusterArn)        tagList = tagListData["tags"](編輯:這段 Python 代碼工作得很好——請參閱評論了解為什么它最初不工作)與其給我一個空列表,list_tags_for_resource()更喜歡拋出一個異常:AttributeError: 'ECS' object has no attribute 'list_tags_for_resource'在這一點上,我想知道......我有過時的包裹嗎?根據我的 pom.xml,我使用的是版本 1.11.604 (Java) 或 boto3-1.9.202 botocore-1.12.202 (Python),據我所知這似乎是最新的(2019 年 8 月)。編輯:我現在已經從命令行嘗試過,并且確實有效:    aws ecs list-tags-for-resource --resource-arn {cluster_arn}
查看完整描述

1 回答

?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

看起來這是 API 中的錯誤。解決方法是暫時使用 ListTagsForResourceRequest() 調用,它會正確返回集群的標簽。


    ListTagsForResourceRequest tagRequest = new ListTagsForResourceRequest().withResourceArn(clusterArn);

    ListTagsForResourceResult tagResult = amazonECS.listTagsForResource(tagRequest);

    List<Tag> tagList = tagResult.getTags();


查看完整回答
反對 回復 2023-05-17
  • 1 回答
  • 0 關注
  • 165 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號