Skip to content

Commit 215aeeb

Browse files
committed
update documentation
1 parent 070f907 commit 215aeeb

File tree

1 file changed

+101
-59
lines changed

1 file changed

+101
-59
lines changed

docs/utilities/parameters.md

Lines changed: 101 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -133,65 +133,6 @@ in order to get data from other regions or use specific credentials.
133133
}
134134
```
135135

136-
## App Configurations
137-
138-
For application configurations in AWS AppConfig, use `AppConfigProvider`.
139-
140-
Alternatively, you can retrieve the instance of provider and configure its underlying SDK client,
141-
in order to get data from other regions or use specific credentials.
142-
143-
144-
=== "AppConfigProvider"
145-
146-
```c# hl_lines="10-13 16-18"
147-
using AWS.Lambda.Powertools.Parameters;
148-
using AWS.Lambda.Powertools.Parameters.AppConfig;
149-
150-
public class Function
151-
{
152-
public async Task<APIGatewayProxyResponse> FunctionHandler
153-
(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
154-
{
155-
// Get AppConfig Provider instance
156-
IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
157-
.DefaultApplication("MyApplicationId")
158-
.DefaultEnvironment("MyEnvironmentId")
159-
.DefaultConfigProfile("MyConfigProfileId");
160-
161-
// Retrieve a single configuration, latest version
162-
IDictionary<string, string?> value = await appConfigProvider
163-
.GetAsync()
164-
.ConfigureAwait(false);
165-
}
166-
}
167-
```
168-
169-
=== "AppConfigProvider with an explicit region"
170-
171-
```c# hl_lines="10-14"
172-
using AWS.Lambda.Powertools.Parameters;
173-
using AWS.Lambda.Powertools.Parameters.AppConfig;
174-
175-
public class Function
176-
{
177-
public async Task<APIGatewayProxyResponse> FunctionHandler
178-
(APIGatewayProxyRequest apigProxyEvent, ILambdaContext context)
179-
{
180-
// Get AppConfig Provider instance
181-
IAppConfigProvider appConfigProvider = ParametersManager.AppConfigProvider
182-
.ConfigureClient(RegionEndpoint.EUCentral1)
183-
.DefaultApplication("MyApplicationId")
184-
.DefaultEnvironment("MyEnvironmentId")
185-
.DefaultConfigProfile("MyConfigProfileId");
186-
187-
// Retrieve a single configuration, latest version
188-
IDictionary<string, string?> value = await appConfigProvider
189-
.GetAsync()
190-
.ConfigureAwait(false);
191-
}
192-
}
193-
```
194-
195136
### Additional arguments
196137

197138
The AWS Systems Manager Parameter Store provider supports two additional arguments for the `Get()` and `GetMultiple()` methods:
@@ -401,6 +342,7 @@ You can retrieve multiple parameters sharing the same `id` by having a sort key
401342
"param-b": "my-value-b",
402343
"param-c": "my-value-c"
403344
}
345+
```
404346

405347
**Customizing DynamoDBProvider**
406348

@@ -437,6 +379,106 @@ DynamoDB provider can be customized at initialization to match your table struct
437379
}
438380
```
439381

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+
440482
## Advanced configuration
441483

442484
### Caching

0 commit comments

Comments
 (0)