fix for duplicate tag keys in secretsmanager (#4900)
This commit is contained in:
parent
206590acf5
commit
7e88a901d9
@ -735,6 +735,16 @@ class SecretsManagerBackend(BaseBackend):
|
|||||||
old_tags = secret.tags
|
old_tags = secret.tags
|
||||||
|
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
|
existing_key_name = next(
|
||||||
|
(
|
||||||
|
old_key
|
||||||
|
for old_key in old_tags
|
||||||
|
if old_key.get("Key") == tag.get("Key")
|
||||||
|
),
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
if existing_key_name:
|
||||||
|
old_tags.remove(existing_key_name)
|
||||||
old_tags.append(tag)
|
old_tags.append(tag)
|
||||||
|
|
||||||
return secret_id
|
return secret_id
|
||||||
|
@ -1282,14 +1282,16 @@ def test_tag_resource(pass_arn):
|
|||||||
conn.tag_resource(
|
conn.tag_resource(
|
||||||
SecretId=secret_id, Tags=[{"Key": "FirstTag", "Value": "SomeValue"},],
|
SecretId=secret_id, Tags=[{"Key": "FirstTag", "Value": "SomeValue"},],
|
||||||
)
|
)
|
||||||
|
conn.tag_resource(
|
||||||
|
SecretId="test-secret", Tags=[{"Key": "FirstTag", "Value": "SomeOtherValue"},],
|
||||||
|
)
|
||||||
conn.tag_resource(
|
conn.tag_resource(
|
||||||
SecretId=secret_id, Tags=[{"Key": "SecondTag", "Value": "AnotherValue"},],
|
SecretId=secret_id, Tags=[{"Key": "SecondTag", "Value": "AnotherValue"},],
|
||||||
)
|
)
|
||||||
|
|
||||||
secrets = conn.list_secrets()
|
secrets = conn.list_secrets()
|
||||||
assert secrets["SecretList"][0].get("Tags") == [
|
assert secrets["SecretList"][0].get("Tags") == [
|
||||||
{"Key": "FirstTag", "Value": "SomeValue"},
|
{"Key": "FirstTag", "Value": "SomeOtherValue"},
|
||||||
{"Key": "SecondTag", "Value": "AnotherValue"},
|
{"Key": "SecondTag", "Value": "AnotherValue"},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user