|
| 1 | +# AWS.Lambda.Powertools.Parameters |
| 2 | + |
| 3 | +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), [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/), or [Amazon DynamoDB](https://aws.amazon.com/dynamodb/). Or bring your own providers. |
| 4 | + |
| 5 | +## Key features |
| 6 | + |
| 7 | +* Retrieve one or multiple parameters from the underlying provider |
| 8 | +* Cache parameter values for a given amount of time (defaults to 5 seconds) |
| 9 | +* Transform parameter values from JSON or base 64 encoded strings |
| 10 | +* Bring your own parameter store provider |
| 11 | + |
| 12 | +## Read the docs |
| 13 | + |
| 14 | +For a full list of features go to [awslabs.github.io/aws-lambda-powertools-dotnet/utilities/parameters/](awslabs.github.io/aws-lambda-powertools-dotnet/utilities/parameters/) |
| 15 | + |
| 16 | +GitHub: <https://github.com/awslabs/aws-lambda-powertools-dotnet/> |
| 17 | + |
| 18 | +## Sample Function using AWS Systems Manager Parameter Store |
| 19 | + |
| 20 | +```csharp |
| 21 | +using AWS.Lambda.Powertools.Logging; |
| 22 | +using AWS.Lambda.Powertools.Parameters; |
| 23 | +using AWS.Lambda.Powertools.Parameters.SimpleSystemsManagement; |
| 24 | + |
| 25 | +namespace HelloWorld; |
| 26 | + |
| 27 | +public class Function |
| 28 | +{ |
| 29 | + [Logging(LogEvent = true)] |
| 30 | + public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest apigwProxyEvent, |
| 31 | + ILambdaContext context) |
| 32 | + { |
| 33 | + // Get SSM Provider instance |
| 34 | + ISsmProvider ssmProvider = ParametersManager.SsmProvider; |
| 35 | + |
| 36 | + // Retrieve a single parameter |
| 37 | + string? value = await ssmProvider |
| 38 | + .GetAsync("/my/parameter") |
| 39 | + .ConfigureAwait(false); |
| 40 | + |
| 41 | + // Retrieve multiple parameters from a path prefix |
| 42 | + // This returns a Dictionary with the parameter name as key |
| 43 | + IDictionary<string, string?> values = await ssmProvider |
| 44 | + .GetMultipleAsync("/my/path/prefix") |
| 45 | + .ConfigureAwait(false); |
| 46 | + |
| 47 | + ... |
| 48 | + |
| 49 | + } |
| 50 | +} |
| 51 | +``` |
0 commit comments