Description
Expected Behaviour
When using the AppConfig Provider
to fetch user specific configurations at runtime based on the identity of the requester that invokes our lambda function, we expect the correct configuration to be returned. Our AppConfig Application and Environment names are used to instantiate a global AppConfig Provider
object at runtime, and the this provider is used to fetch the configuration specific to the requester multiple times throughout the execution of the request in that lambda container. We do not cache the profile and instead rely on the caching that is built into the AppConfig Provider
.
Current Behaviour
What we are seeing is that when multiple requests are being made at the same time from different users (across different lambda invocations), the AppConfig provider will be called to fetch the configuration with the right username, but return the wrong configuration profile (it will be called with user A, but return user B's profile). We have tried turning off caching of the profiles and this did not help. All we are doing is calling that initialized AppConfigProvider with the config_name that is specific to each user when we need to fetch that profile. It is important to note that for each request, we only need to fetch one profile that is scoped to the user who made the request.
Code snippet
# Global AppConfig Provider Object
appconfig_client = AppConfigClient(
application=APPLICATION_NAME,
environment=ENVIRONMENT_NAME,
)
# Method used to fetch the Configuration
def get_config_as_dict(self, config_name: str) -> Dict[str, Any]:
logger.info(f"Fetching configuration: {config_name}...")
return cast(
dict,
self._app_config_client.get(
name=config_name, transform="json", max_age=600
),
)
Possible Solution
No response
Steps to Reproduce
Multiple requests attempting to fetch different configurations at the same time should be able to reproduce this error. The TPS for our service should not be more than 2-3 per second at most. Lambda containers being reused across requests most likely does play a part here.
Powertools for AWS Lambda (Python) version
2.17
AWS Lambda function runtime
3.8
Packaging format used
Lambda Layers
Debugging logs
No response
Metadata
Metadata
Assignees
Type
Projects
Status