feat(SSM): add support for Label filter in get_parameters_by_path (#4542)

This commit is contained in:
Dominik Schubert 2021-11-08 23:58:11 +01:00 committed by GitHub
parent a62e33cacb
commit 78709ce22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -1388,6 +1388,13 @@ class SimpleSystemManagerBackend(BaseBackend):
values = ["/" + value.strip("/") for value in values]
elif key == "Type":
what = parameter.type
elif key == "Label":
what = parameter.labels
# Label filter can only have option="Equals" (also valid implicitly)
if len(what) == 0 or not all(label in values for label in what):
return False
else:
continue
elif key.startswith("tag:"):
what = key[4:] or None
for tag in parameter.tags:

View File

@ -225,6 +225,14 @@ def test_get_parameters_by_path():
"Valid filter keys include: [Type, KeyId].",
)
# Label filter in get_parameters_by_path
client.label_parameter_version(Name="/foo/name2", Labels=["Label1"])
filters = [{"Key": "Label", "Values": ["Label1"]}]
response = client.get_parameters_by_path(Path="/foo", ParameterFilters=filters)
len(response["Parameters"]).should.equal(1)
{p["Name"] for p in response["Parameters"]}.should.equal(set(["/foo/name2"]))
@pytest.mark.parametrize("name", ["test", "my-cool-parameter"])
@mock_ssm