[issue-4283] ssm put_parameter with tags and overwrite should error (#4362)

This commit is contained in:
Jim King 2021-09-30 06:58:04 -04:00 committed by GitHub
parent 8c2d0b0557
commit f50cf51de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -1547,6 +1547,12 @@ class SimpleSystemManagerBackend(BaseBackend):
"1 validation error detected: Value '' at 'value' failed to satisfy"
" constraint: Member must have length greater than or equal to 1."
)
if overwrite and tags:
raise ValidationException(
"Invalid request: tags and overwrite can't be used together. To create a "
"parameter with tags, please remove overwrite flag. To update tags for an "
"existing parameter, please use AddTagsToResource or RemoveTagsFromResource."
)
if name.lower().lstrip("/").startswith("aws") or name.lower().lstrip(
"/"
).startswith("ssm"):

View File

@ -279,6 +279,19 @@ def test_put_parameter(name):
"arn:aws:ssm:us-east-1:{}:parameter/{}".format(ACCOUNT_ID, name)
)
new_data_type = "aws:ec2:image"
with pytest.raises(ClientError) as ex:
response = client.put_parameter(
Name=name,
Description="desc 3",
Value="value 3",
Type="String",
Overwrite=True,
Tags=[{"Key": "foo", "Value": "bar"}],
DataType=new_data_type,
)
assert ex.value.response["Error"]["Code"] == "ValidationException"
response = client.put_parameter(
Name=name,
Description="desc 3",