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

feat: Add Parameters Utility #167

Merged
merged 48 commits into from
May 11, 2023

Conversation

amirkaws
Copy link
Contributor

@amirkaws amirkaws commented Oct 24, 2022

Issue number: #160

Summary

Changes

This PR adds parameters utility to Lambda Powertools for features parity across Powertools languages. it includes supports for AWS Systems Manager Parameter Store, AWS Secrets Manager, AWS AppConfig, Amazon DynamoDB, or bring your own.

User experience

1- Install the package

dotnet nuget add AWS.Lambda.Powertools.Parameters

2- Grants relevant IAM permissions
3- Configure and use relevant parameter provider for example

using AWS.Lambda.Powertools.Parameters;
using AWS.Lambda.Powertools.Parameters.SimpleSystemsManagement;

public class Function
{
    public async Task<APIGatewayProxyResponse> FunctionHandler
        (APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
    {
        // Get SSM Provider instance
        ISsmProvider ssmProvider = ParametersManager.SsmProvider;
            
        // Retrieve a single parameter
        string? value = await ssmProvider
            .GetAsync("/my/parameter")
            .ConfigureAwait(false);
        
        // Retrieve multiple parameters from a path prefix
        // This returns a Dictionary with the parameter name as key
        IDictionary<string, string?> values = await ssmProvider
            .GetMultipleAsync("/my/path/prefix")
            .ConfigureAwait(false);
    }
}

Refer to Parameters read me for more information.

Checklist

Please leave checklist items unchecked if they do not apply to your change.

Is this a breaking change?

No

RFC issue number: #160

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.


View rendered docs/utilities/parameters.md

@auto-assign auto-assign bot requested a review from sliedig October 24, 2022 14:32
@amirkaws amirkaws requested a review from jeastham1993 October 24, 2022 14:33
@github-actions github-actions bot added the feature New features or minor changes label Oct 24, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2022

Codecov Report

Patch coverage: 67.57% and project coverage change: +2.40 🎉

Comparison is base (17de07e) 60.17% compared to head (8c9f41a) 62.58%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #167      +/-   ##
===========================================
+ Coverage    60.17%   62.58%   +2.40%     
===========================================
  Files           42       61      +19     
  Lines         1853     2627     +774     
===========================================
+ Hits          1115     1644     +529     
- Misses         738      983     +245     
Flag Coverage Δ
unittests 62.58% <67.57%> (+2.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
....Lambda.Powertools.Parameters/ParametersManager.cs 0.00% <0.00%> (ø)
...tools.Parameters/SecretsManager/SecretsProvider.cs 33.33% <33.33%> (ø)
...ls.Parameters/Transform/TransformationException.cs 50.00% <50.00%> (ø)
....Parameters/SimpleSystemsManagement/SsmProvider.cs 51.64% <51.64%> (ø)
...Powertools.Parameters/DynamoDB/DynamoDBProvider.cs 58.92% <58.92%> (ø)
...Parameters/Provider/ParameterProviderExtensions.cs 66.66% <66.66%> (ø)
...owertools.Parameters/Provider/ParameterProvider.cs 80.00% <80.00%> (ø)
...wertools.Parameters/Internal/Cache/CacheManager.cs 80.76% <80.76%> (ø)
...iguration/ParameterProviderConfigurationBuilder.cs 83.09% <83.09%> (ø)
...s.Parameters/Internal/Transform/JsonTransformer.cs 85.71% <85.71%> (ø)
... and 9 more

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@hjgraca hjgraca requested review from hjgraca and removed request for jeastham1993 March 14, 2023 11:42
@hjgraca hjgraca linked an issue Mar 28, 2023 that may be closed by this pull request
2 tasks
Copy link
Contributor

@hjgraca hjgraca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please implement the PowertoolsConfiguration SetExecutionEnvironment. To add Parameters to the user agent. Could be on the singleton constructor of the parameters. And add the test. Have a look here and here

Copy link
Contributor

@hjgraca hjgraca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTM

@sliedig sliedig added this to the Parameters - GA Release milestone May 11, 2023
@amirkaws amirkaws merged commit 5d08008 into aws-powertools:develop May 11, 2023
@amirkaws amirkaws deleted the amirkaws-feature-parameters branch May 11, 2023 13:29
@aviv-akhansari
Copy link

I'm wondering why the AppConfig feature was removed?

@hjgraca
Copy link
Contributor

hjgraca commented Feb 28, 2024

@aviv-akhansari thanks for your question. We removed the feature from this pull request because there were some API changes on AppConfig that we could not tackle in time to get this release out.
We were also waiting on customer feedback to get it back, and now we have it 😄 and will begin the work to add AppConfig to Powertools.

Again thanks for using Powertools and we will keep you posted on the progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New features or minor changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC : Parameters utility
5 participants