Skip to content

Docs: Document that getAppConfig can only be reused for the same AppConfig application & environment #3801

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

Closed
1 task done
HaaLeo opened this issue Apr 3, 2025 · 5 comments · Fixed by #3808
Closed
1 task done
Assignees
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation parameters This item relates to the Parameters Utility

Comments

@HaaLeo
Copy link
Contributor

HaaLeo commented Apr 3, 2025

What were you searching in the docs?

Subsequent calls to getAppConfig for different applications/environments fail. Looking at its implementation it make sense because the environment as well as the application arguments are cached.

Therefore, something like this fails with some unintuitive "ConfigurationNotFound" error:

import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';

// This works just fine
let config = await getAppConfig('config1', {
    environment: 'first',
    application: 'myApp',
    transform: 'json'
});
console.log(config);

// This will throw an error
config = await getAppConfig('config2', {
    environment: 'second',
    application: 'myApp',
    transform: 'json'
});
console.log(config);

Is this related to an existing documentation section?

https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parameters/#fetching-app-configurations

How can we improve?

Just state that the applications/environment arguments are cached and one has to go with the AppConfigProvider class if one wants to fetch multiple configurations from multiple apps/environments within the same lambda function.

Got a suggestion in mind?

N/A

Acknowledgment

  • I understand the final update might be different from my proposed suggestion, or refused.
@HaaLeo HaaLeo added documentation Improvements or additions to documentation triage This item has not been triaged by a maintainer, please wait labels Apr 3, 2025
@dreamorosi
Copy link
Contributor

Hi @HaaLeo, thank you for bringing this up.

This is indeed the case, but just to understand better - in which context would you have two app/environment combinations in the same function?

If I remember correctly we implemented it this way because when it comes to AppConfig the idea is to group all the configurations for the same app and environment combinations in the same config entity.

@HaaLeo
Copy link
Contributor Author

HaaLeo commented Apr 3, 2025

Hi @dreamorosi, thx for the swift reply. In our setup each service defines its appconfig configuration. In our CI/CD pipeline multiple services can be deployed at the same time. As stated here one can only deploy one config to one appconfig environment at the same time. In our setup this would lead to conflicts during deployment. Therefore, as a workaround we introduced one environment per stage per service.

That being said we now have a single lambda function acts as single entrypoint / router. This lambda now checks which services' features are en-/disabled to route the request correctly or drop it otherwise. So this lambda function needs to check different appconfig environments.

So I understand that this is rather a uncommon design. That's also why I created this as a documentation enhancement rather than a bug/feature-request.

@dreamorosi dreamorosi added confirmed The scope is clear, ready for implementation parser This item relates to the Parser Utility labels Apr 5, 2025
@dreamorosi dreamorosi self-assigned this Apr 5, 2025
@dreamorosi dreamorosi removed the triage This item has not been triaged by a maintainer, please wait label Apr 5, 2025
@dreamorosi dreamorosi moved this from Triage to Working on it in Powertools for AWS Lambda (TypeScript) Apr 5, 2025
@dreamorosi
Copy link
Contributor

I see, thank you for explaining.

I think it's somewhat an edge case and perhaps there's an opportunity to review the AppConfig topology (let us know if you'd like to talk about that in a call), but I also it doesn't hurt to add a callout to the docs.

I am going to open a PR to add this

Image

@dreamorosi dreamorosi moved this from Working on it to Pending customer in Powertools for AWS Lambda (TypeScript) Apr 5, 2025
@dreamorosi dreamorosi moved this from Pending customer to Pending review in Powertools for AWS Lambda (TypeScript) Apr 5, 2025
@github-project-automation github-project-automation bot moved this from Pending review to Coming soon in Powertools for AWS Lambda (TypeScript) Apr 7, 2025
Copy link
Contributor

github-actions bot commented Apr 7, 2025

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed confirmed The scope is clear, ready for implementation labels Apr 7, 2025
@dreamorosi dreamorosi added parameters This item relates to the Parameters Utility and removed parser This item relates to the Parser Utility labels Apr 7, 2025
Copy link
Contributor

github-actions bot commented Apr 8, 2025

This is now released under v2.18.0 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Apr 8, 2025
@dreamorosi dreamorosi moved this from Coming soon to Shipped in Powertools for AWS Lambda (TypeScript) Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped documentation Improvements or additions to documentation parameters This item relates to the Parameters Utility
Projects
2 participants