aws-powertools / powertools-lambda-dotnet

Powertools is a developer toolkit to implement Serverless best practices and increase developer velocity.
https://docs.powertools.aws.dev/lambda/dotnet/
MIT No Attribution
152 stars 24 forks source link

feat: Add AppConfig parameter provider #559

Closed amirkaws closed 6 months ago

amirkaws commented 6 months ago

Issue number: #558

Summary

This PR enhanced the parameters utility functionality and adds support for AppConfig and FeatureFlags

Changes

Parameters utility has been modified to add support for AppConfig

User experience

// Get AppConfig Provider instance
IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
    .DefaultApplication("MyApplicationId")
    .DefaultEnvironment("MyEnvironmentId")
    .DefaultConfigProfile("MyConfigProfileId");

// Retrieve a single configuration, latest version
IDictionary<string, string?> value = await appConfigProvider
    .GetAsync()
    .ConfigureAwait(false);

// Check if feature flag is enabled
var isFeatureFlagEnabled = await appConfigProvider
    .IsFeatureFlagEnabledAsync("MyFeatureFlag")
    .ConfigureAwait(false);

if (isFeatureFlagEnabled)
{
    // Retrieve an attribute value of the feature flag
    var strAttValue = await appConfigProvider
        .GetFeatureFlagAttributeValueAsync<string>("MyFeatureFlag", "StringAttribute")
        .ConfigureAwait(false);

    // Retrieve another attribute value of the feature flag
    var numberAttValue = await appConfigProvider
        .GetFeatureFlagAttributeValueAsync<int>("MyFeatureFlag", "NumberAttribute")
        .ConfigureAwait(false);
}

Checklist

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

Is this a breaking change? **RFC issue number**: 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.

sonarcloud[bot] commented 6 months ago

Quality Gate Passed Quality Gate passed

Issues
5 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
2.6% Duplication on New Code

See analysis details on SonarCloud

hjgraca commented 6 months ago

cc @aviv-akhansari. AppConfig provider work

aviv-akhansari commented 6 months ago

This is awesome. Thank you.