diff --git a/store/ssmstore.go b/store/ssmstore.go index 0e7774c8..e453eca4 100644 --- a/store/ssmstore.go +++ b/store/ssmstore.go @@ -172,7 +172,7 @@ func (s *SSMStore) List(service string, includeValues bool) ([]Secret, error) { Filters: []*ssm.ParametersFilter{ { Key: aws.String("Name"), - Values: []*string{aws.String(service)}, + Values: []*string{aws.String(service + ".")}, }, }, NextToken: nextToken, diff --git a/store/ssmstore_test.go b/store/ssmstore_test.go index 3331f336..030bb11f 100644 --- a/store/ssmstore_test.go +++ b/store/ssmstore_test.go @@ -292,6 +292,16 @@ func TestList(t *testing.T) { assert.Equal(t, "value", *secret.Value) } }) + + t.Run("List should only return exact matches on service name", func(t *testing.T) { + store.Write(SecretId{Service: "match", Key: "a"}, "val") + store.Write(SecretId{Service: "matchlonger", Key: "a"}, "val") + + s, err := store.List("match", false) + assert.Nil(t, err) + assert.Equal(t, 1, len(s)) + assert.Equal(t, "match.a", s[0].Meta.Key) + }) } func TestHistory(t *testing.T) {