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

Feature request: improve return types for SSM Parameters #1386

Closed
1 of 2 tasks
dreamorosi opened this issue Mar 28, 2023 · 1 comment · Fixed by #1387
Closed
1 of 2 tasks

Feature request: improve return types for SSM Parameters #1386

dreamorosi opened this issue Mar 28, 2023 · 1 comment · Fixed by #1387
Assignees
Labels
completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility parameters This item relates to the Parameters Utility

Comments

@dreamorosi
Copy link
Contributor

Use case

Note
This issue was opened as a result of this exchange on our Discord Server.

Currently when retrieving parameter values from AWS SSM Parameter Store, the Parameter utility has somewhat generic return types.

For example, when calling the getParameter function the current return type is string, Record<string, unknown>, undefined. These types were chosen because they map to the following cases:

  • string applies in most cases since SSM supports string values only
  • Record<string, unknown> applies whenever a transform: 'json' is applied - in this case Parameters parses the value and returns an object
  • undefined is returned whenever a parameter is not found

Given that the utility knows both the types returned by the API and the transformation to be applied, there's an opportunity to improve the return types by applying some heuristics.

Solution/User Experience

With improved return types, the getParameter (as well class-based correspondent and potentially the getParameters), users should be able to obtain stronger typing:

// When we pass transform: 'json', the result will be a Record<string, unknown> because we parse the API result to an object
const objectParam: Record<string, unknown> | undefined = await getParameter('my/param', { transform: 'json' });
    
// When we pass an object that has no transform, then the result will be a string as we return it straight from the API
const param: string | undefined = await getParameter('my/param', { decrypt: true });

// When we don't pass any options object (so also no transform), then the result should be a string as well
const param1: string | undefined = await getParameter('my/param');

Additionally, you can check this TS Playground.

Alternative solutions

N/A

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@dreamorosi dreamorosi added parameters This item relates to the Parameters Utility feature-request This item refers to a feature request for an existing or new utility confirmed The scope is clear, ready for implementation labels Mar 28, 2023
@dreamorosi dreamorosi added this to the Parameters - GA Release milestone Mar 28, 2023
@dreamorosi dreamorosi self-assigned this Mar 28, 2023
@dreamorosi dreamorosi linked a pull request Mar 28, 2023 that will close this issue
13 tasks
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in AWS Lambda Powertools for TypeScript Apr 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2023

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues 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 the pending-release This item has been merged and will be released soon label Apr 5, 2023
@dreamorosi dreamorosi 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 confirmed The scope is clear, ready for implementation labels Apr 11, 2023
@dreamorosi dreamorosi moved this from Coming soon to Shipped in AWS Lambda Powertools for TypeScript Apr 11, 2023
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 feature-request This item refers to a feature request for an existing or new utility parameters This item relates to the Parameters Utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant