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: support providing aws sdk v3 client #1222

Closed
1 of 2 tasks
dreamorosi opened this issue Jan 10, 2023 · 3 comments · Fixed by #1260
Closed
1 of 2 tasks

Feature request: support providing aws sdk v3 client #1222

dreamorosi opened this issue Jan 10, 2023 · 3 comments · Fixed by #1260
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

dreamorosi commented Jan 10, 2023

Use case

The upcoming Parameters utility should allow customers to pass their own AWS SDK v3 client to a given provider.

This is useful for those cases in which a client is already available, for tracing the requests made by the client, or for testing (injection).

The feature is supported by the Python's version and already present in the documentation, however the implementation was left out initially.

Solution/User Experience

Note
The example below shows the SSMProvider, but the feature should be supported by all other providers that use clients

import { SSMProvider } from '@aws-lambda-powertools/parameters/ssm';
import { SSMClient } from '@aws-sdk/client-ssm';

// construct your clients with any custom configuration
const ssmClient = new SSMClient({ region: 'us-east-1' });
// pass the client to the provider
const parametersProvider = new SSMProvider({ awsSdkV3Client: ssmClient });

export const handler = async (): Promise<void> => {
  // Retrieve a single parameter
  const parameter = await parametersProvider.get('/my/parameter');
  console.log(parameter);
};

Alternative solutions

N/A

Acknowledgment

@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 Jan 10, 2023
@dreamorosi dreamorosi added this to the Parameters - Beta release milestone Jan 10, 2023
@shdq
Copy link
Contributor

shdq commented Jan 12, 2023

Hey, @dreamorosi! Let's implement this.

The plan is to use a client that was passed to the provider constructor in awsSdkV3Client, but first, check if it is an instance of ProviderClient. If it is not, there are two options: throw an error or initialize a new valid client. I'm for throwing the error because initializing a new client wouldn't be what the user may expect. What do you think?

If there aren't any other things to consider, I can start working on the PR.

@dreamorosi
Copy link
Contributor Author

Hey Sergei, sure let's do it.

I actually initially didn't think of making any checks, but it's a good point. Let's do a simple check on whether the client passed is an instance of the class that we expect, and if not, we throw an error like you suggested.

We should also modify the interface/type of the constructor options object to make either clientConfig or awsSdkV3Client mutually exclusive.

Other than that, at the moment I can't think of anything else!

Happy for you to work on this :)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 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 Feb 6, 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 Mar 2, 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
2 participants