Skip to content

Bug: AppConfig value retrieval fails when there is more than 24 hours between calls  #1798

Closed
@mareksnincak

Description

@mareksnincak

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:

  1. token is set in https://github.com/aws-powertools/powertools-lambda-typescript/blob/v1.16.0/packages/parameters/src/appconfig/AppConfigProvider.ts#L316
  2. 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

  1. Initiate app config provider
  2. call get method to retrieve value - this will cache the token from GetLatestConfiguration command
  3. wait more than 24 hours - without killing the environment and calling get method again
  4. 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

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedparametersThis item relates to the Parameters Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions