Skip to content

Docs: Incorrect example for SSMProvider.get_multiple #2749

Closed
@bram-tv

Description

@bram-tv

What were you searching in the docs?

Documentation for the get_multiple call of the SSMProvider.

Is this related to an existing documentation section?

https://docs.powertools.aws.dev/lambda/python/latest/api/utilities/parameters/ssm.html

How can we improve?

The examples listed under:

  • Retrieves multiple parameter values from Systems Manager Parameter Store using a path prefix
  • Retrieves multiple parameter values from Systems Manager Parameter Store passing options to the SDK call

do not appear to be correct.

Taking the first example:

>>> from aws_lambda_powertools.utilities.parameters import SSMProvider
>>> ssm_provider = SSMProvider()
>>>
>>> values = ssm_provider.get_multiple("/my/path/prefix")
>>>
>>> for key, value in values.items():
...     print(key, value)
/my/path/prefix/a   Parameter value a
/my/path/prefix/b   Parameter value b
/my/path/prefix/c   Parameter value c

This shows that /my/path/prefix/ is part of the key name but that is not (or no longer the case).
Looking at the code:

                # Standardize the parameter name
                # The parameter name returned by SSM will contain the full path.
                # However, for readability, we should return only the part after
                # the path.
                name = parameter["Name"]
                if name.startswith(path):
                    name = name[len(path) :]
                name = name.lstrip("/")

It always removes the path from the name.

Got a suggestion in mind?

Updates the example to:

>>> ...
>>> for key, value in values.items():
...     print(key, value)
a   Parameter value a
b   Parameter value b
c   Parameter value c

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions