Skip to content

Commit 97a49e0

Browse files
authored
Merge pull request #566 from aws-powertools/develop
chore: Sync main with develop
2 parents 6f764a2 + 9148d02 commit 97a49e0

File tree

27 files changed

+3003
-80
lines changed

27 files changed

+3003
-80
lines changed

docs/utilities/parameters.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Utility
44
---
55

66
<!-- markdownlint-disable MD013 -->
7-
The Parameters utility provides high-level functionality to retrieve one or multiple parameter values from [AWS Systems Manager Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html){target="_blank"}, [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/){target="_blank"}, or [Amazon DynamoDB](https://aws.amazon.com/dynamodb/){target="_blank"}. We also provide extensibility to bring your own providers.
7+
The Parameters utility provides high-level functionality to retrieve one or multiple parameter values from [AWS Systems Manager Parameter Store](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html){target="_blank"}, [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/){target="_blank"}, [Amazon DynamoDB](https://aws.amazon.com/dynamodb/){target="_blank"}, or [AWS AppConfig](https://docs.aws.amazon.com/appconfig/latest/userguide/what-is-appconfig.html){target="_blank"}. We also provide extensibility to bring your own providers.
88

99
## Key features
1010

@@ -33,6 +33,7 @@ This utility requires additional permissions to work as expected. See the table
3333
| Secrets Manager | `SecretsProvider.Get(string)` `SecretsProvider.Get<T>(string)` | `secretsmanager:GetSecretValue` |
3434
| DynamoDB | `DynamoDBProvider.Get(string)` `DynamoDBProvider.Get<T>(string)` | `dynamodb:GetItem` |
3535
| DynamoDB | `DynamoDBProvider.GetMultiple(string)` `DynamoDBProvider.GetMultiple<T>(string)` | `dynamodb:Query` |
36+
| App Config | `AppConfigProvider.Get()` | `appconfig:StartConfigurationSession` `appconfig:GetLatestConfiguration` |
3637

3738
## SSM Parameter Store
3839

@@ -341,6 +342,7 @@ You can retrieve multiple parameters sharing the same `id` by having a sort key
341342
"param-b": "my-value-b",
342343
"param-c": "my-value-c"
343344
}
345+
```
344346

345347
**Customizing DynamoDBProvider**
346348

@@ -377,6 +379,106 @@ DynamoDB provider can be customized at initialization to match your table struct
377379
}
378380
```
379381

382+
## App Configurations
383+
384+
For application configurations in AWS AppConfig, use `AppConfigProvider`.
385+
386+
Alternatively, you can retrieve the instance of provider and configure its underlying SDK client,
387+
in order to get data from other regions or use specific credentials.
388+
389+
=== "AppConfigProvider"
390+
391+
```c# hl_lines="10-13 16-18"
392+
using AWS.Lambda.Powertools.Parameters;
393+
using AWS.Lambda.Powertools.Parameters.AppConfig;
394+
395+
public class Function
396+
{
397+
public async Task<APIGatewayProxyResponse> FunctionHandler
398+
(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
399+
{
400+
// Get AppConfig Provider instance
401+
IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
402+
.DefaultApplication("MyApplicationId")
403+
.DefaultEnvironment("MyEnvironmentId")
404+
.DefaultConfigProfile("MyConfigProfileId");
405+
406+
// Retrieve a single configuration, latest version
407+
IDictionary<string, string?> value = await appConfigProvider
408+
.GetAsync()
409+
.ConfigureAwait(false);
410+
}
411+
}
412+
```
413+
414+
=== "AppConfigProvider with an explicit region"
415+
416+
```c# hl_lines="10-14"
417+
using AWS.Lambda.Powertools.Parameters;
418+
using AWS.Lambda.Powertools.Parameters.AppConfig;
419+
420+
public class Function
421+
{
422+
public async Task<APIGatewayProxyResponse> FunctionHandler
423+
(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
424+
{
425+
// Get AppConfig Provider instance
426+
IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
427+
.ConfigureClient(RegionEndpoint.EUCentral1)
428+
.DefaultApplication("MyApplicationId")
429+
.DefaultEnvironment("MyEnvironmentId")
430+
.DefaultConfigProfile("MyConfigProfileId");
431+
432+
// Retrieve a single configuration, latest version
433+
IDictionary<string, string?> value = await appConfigProvider
434+
.GetAsync()
435+
.ConfigureAwait(false);
436+
}
437+
}
438+
```
439+
440+
**Using AWS AppConfig Feature Flags**
441+
442+
Feature flagging is a powerful tool that allows safely pushing out new features in a measured and usually gradual way. AppConfig provider offers helper methods to make it easier to work with feature flags.
443+
444+
=== "AppConfigProvider"
445+
446+
```c# hl_lines="10-13 16-18 23-25"
447+
using AWS.Lambda.Powertools.Parameters;
448+
using AWS.Lambda.Powertools.Parameters.AppConfig;
449+
450+
public class Function
451+
{
452+
public async Task<APIGatewayProxyResponse> FunctionHandler
453+
(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
454+
{
455+
// Get AppConfig Provider instance
456+
IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
457+
.DefaultApplication("MyApplicationId")
458+
.DefaultEnvironment("MyEnvironmentId")
459+
.DefaultConfigProfile("MyConfigProfileId");
460+
461+
// Check if feature flag is enabled
462+
var isFeatureFlagEnabled = await appConfigProvider
463+
.IsFeatureFlagEnabledAsync("MyFeatureFlag")
464+
.ConfigureAwait(false);
465+
466+
if (isFeatureFlagEnabled)
467+
{
468+
// Retrieve an attribute value of the feature flag
469+
var strAttValue = await appConfigProvider
470+
.GetFeatureFlagAttributeValueAsync<string>("MyFeatureFlag", "StringAttribute")
471+
.ConfigureAwait(false);
472+
473+
// Retrieve another attribute value of the feature flag
474+
var numberAttValue = await appConfigProvider
475+
.GetFeatureFlagAttributeValueAsync<int>("MyFeatureFlag", "NumberAttribute")
476+
.ConfigureAwait(false);
477+
}
478+
}
479+
}
480+
```
481+
380482
## Advanced configuration
381483

382484
### Caching

examples/BatchProcessing/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<ItemGroup>
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
10-
<PackageReference Include="AWS.Lambda.Powertools.BatchProcessing" Version="0.0.1-preview" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
10+
<PackageReference Include="AWS.Lambda.Powertools.BatchProcessing" Version="1.1.0" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.5.0" />
1212
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
1313
</ItemGroup>
1414
</Project>

examples/Idempotency/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Idempotency" Version="1.0.0" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Idempotency" Version="1.1.0" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.5.0" />
1313
</ItemGroup>
1414
</Project>

examples/Logging/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.5.0" />
1212
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.201.13" />
1313
</ItemGroup>
1414
</Project>

examples/Metrics/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.5.3" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.5.0" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.6.0" />
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.201.13" />
1414
</ItemGroup>
1515
</Project>

examples/Parameters/src/HelloWorld/HelloWorld.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Parameters" Version="1.1.2" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Parameters" Version="1.2.0" />
1212
</ItemGroup>
1313
</Project>

examples/ServerlessApi/src/LambdaPowertoolsAPI/LambdaPowertoolsAPI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
</PropertyGroup>
1414
<ItemGroup>
1515
<PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="8.1.0" />
16-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
17-
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.5.3" />
18-
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.3.2" />
16+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.5.0" />
17+
<PackageReference Include="AWS.Lambda.Powertools.Metrics" Version="1.6.0" />
18+
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.4.0" />
1919
</ItemGroup>
2020
</Project>

examples/Tracing/src/HelloWorld/HelloWorld.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
99
<PackageReference Include="Amazon.Lambda.APIGatewayEvents" Version="2.6.0" />
1010
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.1" />
11-
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.4.4" />
12-
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.3.2" />
11+
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="1.5.0" />
12+
<PackageReference Include="AWS.Lambda.Powertools.Tracing" Version="1.4.0" />
1313
<PackageReference Include="AWSSDK.DynamoDBv2" Version="3.7.201.13" />
1414
</ItemGroup>
1515
</Project>

libraries/src/AWS.Lambda.Powertools.Idempotency/AWS.Lambda.Powertools.Idempotency.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<!-- Package versions are Centrally managed in Directory.Packages.props file -->
1414
<!-- More info https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
1515
<PackageReference Include="Amazon.Lambda.Core" />
16-
<PackageReference Include="AWSSDK.DynamoDBv2"/>
17-
<PackageReference Include="JmesPath.Net"/>
16+
<PackageReference Include="AWSSDK.DynamoDBv2" />
17+
<PackageReference Include="JmesPath.Net" />
1818
<ProjectReference Include="..\AWS.Lambda.Powertools.Common\AWS.Lambda.Powertools.Common.csproj" PrivateAssets="all" />
1919
</ItemGroup>
2020

libraries/src/AWS.Lambda.Powertools.Parameters/AWS.Lambda.Powertools.Parameters.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
<ItemGroup>
1414
<!-- Package versions are Centrally managed in Directory.Packages.props file -->
1515
<!-- More info https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
16-
<PackageReference Include="AWSSDK.DynamoDBv2"/>
17-
<PackageReference Include="AWSSDK.SecretsManager"/>
18-
<PackageReference Include="AWSSDK.SimpleSystemsManagement"/>
19-
<PackageReference Include="Microsoft.Extensions.Configuration"/>
16+
<PackageReference Include="AWSSDK.AppConfig" />
17+
<PackageReference Include="AWSSDK.AppConfigData" />
18+
<PackageReference Include="AWSSDK.DynamoDBv2" />
19+
<PackageReference Include="AWSSDK.SecretsManager" />
20+
<PackageReference Include="AWSSDK.SimpleSystemsManagement" />
21+
<PackageReference Include="Microsoft.Extensions.Configuration" />
2022
<ProjectReference Include="..\AWS.Lambda.Powertools.Common\AWS.Lambda.Powertools.Common.csproj" PrivateAssets="All" />
2123
</ItemGroup>
2224

0 commit comments

Comments
 (0)