Skip to content

Commit 0b0b38b

Browse files
dreamorosiAndrea Amorosiheitorlessa
authored
docs(parameters): auto-transforming values based on suffix (#573)
Co-authored-by: Andrea Amorosi <[email protected]> Co-authored-by: heitorlessa <[email protected]>
1 parent cb8169e commit 0b0b38b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/utilities/parameters.md

+35
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,41 @@ For example, if you have three parameters, */param/a*, */param/b* and */param/c*
437437
values = ssm_provider.get_multiple("/param", transform="json", raise_on_transform_error=True)
438438
```
439439

440+
#### Auto-transform values on suffix
441+
442+
If you use `transform` with `get_multiple()`, you might want to retrieve and transform parameters encoded in different formats.
443+
444+
You can do this with a single request by using `transform="auto"`. This will instruct any Parameter to to infer its type based on the suffix and transform it accordingly.
445+
446+
!!! info "`transform="auto"` feature is available across all providers, including the high level functions"
447+
448+
=== "transform_auto.py"
449+
450+
```python hl_lines="6"
451+
from aws_lambda_powertools.utilities import parameters
452+
453+
ssm_provider = parameters.SSMProvider()
454+
455+
def handler(event, context):
456+
values = ssm_provider.get_multiple("/param", transform="auto")
457+
```
458+
459+
For example, if you have two parameters with the following suffixes `.json` and `.binary`:
460+
461+
| Parameter name | Parameter value |
462+
| --------------- | -------------------- |
463+
| /param/a.json | [some encoded value] |
464+
| /param/a.binary | [some encoded value] |
465+
466+
The return of `ssm_provider.get_multiple("/param", transform="auto")` call will be a dictionary like:
467+
468+
```json
469+
{
470+
"a.json": [some value],
471+
"b.binary": [some value]
472+
}
473+
```
474+
440475
### Passing additional SDK arguments
441476

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

0 commit comments

Comments
 (0)