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

fix(parameter): improve AppConfig cached configuration retrieval #3195

Merged
9 changes: 6 additions & 3 deletions aws_lambda_powertools/utilities/parameters/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(
self.current_version = ""

self._next_token: Dict[str, str] = {} # nosec - token for get_latest_configuration executions
self.last_returned_value = ""
self.last_returned_value: Dict[str, str] = {}

def _get(self, name: str, **sdk_options) -> str:
"""
Expand All @@ -126,10 +126,13 @@ def _get(self, name: str, **sdk_options) -> str:
return_value = response["Configuration"].read()
self._next_token[name] = response["NextPollConfigurationToken"]

# The return of get_latest_configuration can be null because this value is supposed to be cached
# on the customer side. We created a dict with the last returned value for the specific configuration
# See https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/appconfigdata/client/get_latest_configuration.html
rubenfonseca marked this conversation as resolved.
Show resolved Hide resolved
if return_value:
self.last_returned_value = return_value
self.last_returned_value[name] = return_value

return self.last_returned_value
return self.last_returned_value[name]

def _get_multiple(self, path: str, **sdk_options) -> Dict[str, str]:
"""
Expand Down