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
158 stars 25 forks source link

Feature request: Add support for AWS AppConfig into the Parameters #558

Closed amirkaws closed 7 months ago

amirkaws commented 8 months ago

Use case

Support reading Config Value and Feature Flags from AWS AppConfig

Solution/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);
}

Alternative solutions

N/A

Acknowledgment

amirkaws commented 7 months ago

Released 1.9.0