ECS: Fix a bug where a cluster cannot be tagged after creation (#6226)
This commit is contained in:
parent
0a19243581
commit
3e21ddd606
@ -2011,7 +2011,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
||||
def tag_resource(self, resource_arn: str, tags: List[Dict[str, str]]) -> None:
|
||||
parsed_arn = self._parse_resource_arn(resource_arn)
|
||||
resource = self._get_resource(resource_arn, parsed_arn)
|
||||
resource.tags = self._merge_tags(resource.tags, tags)
|
||||
resource.tags = self._merge_tags(resource.tags or [], tags)
|
||||
|
||||
def _merge_tags(
|
||||
self, existing_tags: List[Dict[str, str]], new_tags: List[Dict[str, str]]
|
||||
|
@ -115,7 +115,16 @@ def test_list_clusters():
|
||||
def test_create_cluster_with_tags():
|
||||
client = boto3.client("ecs", region_name="us-east-1")
|
||||
tag_list = [{"key": "tagName", "value": "TagValue"}]
|
||||
cluster = client.create_cluster(clusterName="c_with_tags", tags=tag_list)["cluster"]
|
||||
cluster = client.create_cluster(clusterName="c1")["cluster"]
|
||||
|
||||
resp = client.list_tags_for_resource(resourceArn=cluster["clusterArn"])
|
||||
assert "tags" not in resp
|
||||
|
||||
client.tag_resource(resourceArn=cluster["clusterArn"], tags=tag_list)
|
||||
tags = client.list_tags_for_resource(resourceArn=cluster["clusterArn"])["tags"]
|
||||
tags.should.equal([{"key": "tagName", "value": "TagValue"}])
|
||||
|
||||
cluster = client.create_cluster(clusterName="c2", tags=tag_list)["cluster"]
|
||||
|
||||
tags = client.list_tags_for_resource(resourceArn=cluster["clusterArn"])["tags"]
|
||||
tags.should.equal([{"key": "tagName", "value": "TagValue"}])
|
||||
|
Loading…
Reference in New Issue
Block a user