Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(parameters): auto-transforming values based on suffix #573

Merged
merged 3 commits into from
Aug 10, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions docs/utilities/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,39 @@ For example, if you have three parameters, */param/a*, */param/b* and */param/c*
values = ssm_provider.get_multiple("/param", transform="json", raise_on_transform_error=True)
```

#### Infer transform from parameter suffix with `get_multiple()`

If you use `transform` with `get_multiple()`, you might want to retrieve and transform parameters encoded in different formats. You can do this with a single request by using `transform="auto"` and let the infer the transform type to use based on the parameter suffix.

!!! info "The `transform="auto"` feature is available across all providers, including the high level functions"

=== "partial_failures.py"

````python hl_lines="6"
from aws_lambda_powertools.utilities import parameters

ssm_provider = parameters.SSMProvider()

def handler(event, context):
values = ssm_provider.get_multiple("/param", transform="auto")

For example, if you have two parameters with the following suffixes `.json` and `.binary`:

| Parameter name | Parameter value |
| --------------- | ----------------------- |
| /param/a.json | [some encoded value] |
| /param/a.binary | [some encoded value] |

The return of `ssm_provider.get_multiple("/param", transform="auto")` call will be a dictionary like:

```json
{
"a.json": [some value],
"b.binary": [some value]
}
```
````
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and then remove this one?


### Passing additional SDK arguments

You can use arbitrary keyword arguments to pass it directly to the underlying SDK method.
Expand Down