Closed
Description
Expected Behaviour
AppConfigProvider get method shouldn't fail, when there is more than 24 hours between calls.
Current Behaviour
AppConfigProvider get method fails, when there is more than 24 hours between calls.
Cause:
- token is set in https://github.com/aws-powertools/powertools-lambda-typescript/blob/v1.16.0/packages/parameters/src/appconfig/AppConfigProvider.ts#L316
- token is reused in https://github.com/aws-powertools/powertools-lambda-typescript/blob/v1.16.0/packages/parameters/src/appconfig/AppConfigProvider.ts#L289 even when it already expired - according to https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-retrieving-the-configuration.html tokens are only valid for 24 hours
Code snippet
const appConfigProvider = new AppConfigProvider({
application: "my-app",
environment: "my-env",
clientConfig: { region: "us-east-1" },
});
await appConfigProvider.get("my-config");
// Wait more than 24 hours...
await appConfigProvider.get("my-config");
Steps to Reproduce
- Initiate app config provider
- call
get
method to retrieve value - this will cache the token fromGetLatestConfiguration
command - wait more than 24 hours - without killing the environment and calling get method again
- call
get
method to retrieve value - this will reuse expired token from previous call
Possible Solution
Set cache to expire after e.g. 23 hours - cache retrieval in https://github.com/aws-powertools/powertools-lambda-typescript/blob/v1.16.0/packages/parameters/src/appconfig/AppConfigProvider.ts#L289 should be updated to not return expired token.
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
18.x
Packaging format used
npm
Execution logs
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped