ECS - Fix tag/untag for with multiple services in cluster (#4649)
This commit is contained in:
parent
c6815c1a4b
commit
1993e3f4ec
@ -1568,7 +1568,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
||||
for service in self.services.values():
|
||||
if service.arn == resource_arn:
|
||||
service.tags = self._merge_tags(service.tags, tags)
|
||||
return {}
|
||||
return {}
|
||||
else:
|
||||
raise ServiceNotFoundException
|
||||
raise NotImplementedError()
|
||||
@ -1594,7 +1594,7 @@ class EC2ContainerServiceBackend(BaseBackend):
|
||||
service.tags = [
|
||||
tag for tag in service.tags if tag["key"] not in tag_keys
|
||||
]
|
||||
return {}
|
||||
return {}
|
||||
else:
|
||||
raise ServiceNotFoundException
|
||||
raise NotImplementedError()
|
||||
|
@ -2766,26 +2766,50 @@ def test_ecs_service_tag_resource():
|
||||
}
|
||||
],
|
||||
)
|
||||
response = client.create_service(
|
||||
create_response2 = client.create_service(
|
||||
cluster="test_ecs_cluster",
|
||||
serviceName="test_ecs_service_2",
|
||||
taskDefinition="test_ecs_task",
|
||||
desiredCount=1,
|
||||
)
|
||||
create_response = client.create_service(
|
||||
cluster="test_ecs_cluster",
|
||||
serviceName="test_ecs_service",
|
||||
taskDefinition="test_ecs_task",
|
||||
desiredCount=2,
|
||||
)
|
||||
|
||||
client.tag_resource(
|
||||
resourceArn=response["service"]["serviceArn"],
|
||||
resourceArn=create_response["service"]["serviceArn"],
|
||||
tags=[
|
||||
{"key": "createdBy", "value": "moto-unittest"},
|
||||
{"key": "foo", "value": "bar"},
|
||||
],
|
||||
)
|
||||
client.tag_resource(
|
||||
resourceArn=create_response2["service"]["serviceArn"],
|
||||
tags=[
|
||||
{"key": "createdBy-2", "value": "moto-unittest-2"},
|
||||
{"key": "foo-2", "value": "bar-2"},
|
||||
],
|
||||
)
|
||||
response = client.list_tags_for_resource(
|
||||
resourceArn=response["service"]["serviceArn"]
|
||||
resourceArn=create_response["service"]["serviceArn"]
|
||||
)
|
||||
type(response["tags"]).should.be(list)
|
||||
response["tags"].should.equal(
|
||||
[{"key": "createdBy", "value": "moto-unittest"}, {"key": "foo", "value": "bar"}]
|
||||
)
|
||||
response2 = client.list_tags_for_resource(
|
||||
resourceArn=create_response2["service"]["serviceArn"]
|
||||
)
|
||||
type(response2["tags"]).should.be(list)
|
||||
response2["tags"].should.equal(
|
||||
[
|
||||
{"key": "createdBy-2", "value": "moto-unittest-2"},
|
||||
{"key": "foo-2", "value": "bar-2"},
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@mock_ecs
|
||||
|
Loading…
Reference in New Issue
Block a user