Skip to content

Commit d70eaa1

Browse files
author
Michael Brewer
committed
fix(ssm): Make decrypt an explicit option
1 parent 6736af2 commit d70eaa1

File tree

1 file changed

+41
-1
lines changed
  • aws_lambda_powertools/utilities/parameters

1 file changed

+41
-1
lines changed

aws_lambda_powertools/utilities/parameters/ssm.py

+41-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import boto3
99
from botocore.config import Config
1010

11-
from .base import DEFAULT_PROVIDERS, BaseProvider
11+
from .base import DEFAULT_MAX_AGE_SECS, DEFAULT_PROVIDERS, BaseProvider
1212

1313

1414
class SSMProvider(BaseProvider):
@@ -86,6 +86,46 @@ def __init__(
8686

8787
super().__init__()
8888

89+
def get(
90+
_,
91+
name: str,
92+
max_age: int = DEFAULT_MAX_AGE_SECS,
93+
transform: Optional[str] = None,
94+
decrypt: bool = False,
95+
**sdk_options
96+
) -> Union[str, list, dict, bytes]:
97+
"""
98+
Retrieve a parameter value or return the cached value
99+
100+
Parameters
101+
----------
102+
name: str
103+
Parameter name
104+
max_age: int
105+
Maximum age of the cached value
106+
transform: str
107+
Optional transformation of the parameter value. Supported values
108+
are "json" for JSON strings and "binary" for base 64 encoded
109+
values.
110+
decrypt: bool, optional
111+
If the parameter value should be decrypted
112+
sdk_options: dict, optional
113+
Arguments that will be passed directly to the underlying API call
114+
115+
Raises
116+
------
117+
GetParameterError
118+
When the parameter provider fails to retrieve a parameter value for
119+
a given name.
120+
TransformParameterError
121+
When the parameter provider fails to transform a parameter value.
122+
"""
123+
124+
# Add to `decrypt` sdk_options to we can have an explicit option for this
125+
sdk_options["decrypt"] = decrypt
126+
127+
return super().get(name, max_age, transform, **sdk_options)
128+
89129
def _get(self, name: str, decrypt: bool = False, **sdk_options) -> str:
90130
"""
91131
Retrieve a parameter value from AWS Systems Manager Parameter Store

0 commit comments

Comments
 (0)