It initializes the AppConfigProvider class. *
The configuration object.
Protected
configurationProtected
storeProtected
valueProtected
_getRetrieve a configuration from AWS AppConfig.
Name of the configuration or its ID
Optional
options: AppConfigGetOptionsSDK options to propagate to StartConfigurationSession
API call
Protected
_getRetrieve a configuration profile from AWS AppConfig.
The name of the configuration profile or its ID
Optional
options: ObjectOptions to configure the provider
import { AppConfigProvider } from '@aws-lambda-powertools/parameters/appconfig';
const configProvider = new AppConfigProvider({
application: 'my-app',
environment: 'prod',
});
export const handler = async (): Promise<void> => {
// Retrieve a configuration profile
const encodedConfig = await configProvider.get('my-config');
const config = new TextDecoder('utf-8').decode(encodedConfig);
};
You can customize the retrieval of the configuration profile by passing options to the function:
maxAge
- The maximum age of the value in cache before fetching a new one (in seconds) (default: 5)forceFetch
- Whether to always fetch a new value from the store regardless if already available in cachetransform
- Whether to transform the value before returning it. Supported values: json
, binary
sdkOptions
- Extra options to pass to the AWS SDK v3 for JavaScript clientFor usage examples check AppConfigProvider.
https://docs.powertools.aws.dev/lambda/typescript/latest/utilities/parameters/
Generated using TypeDoc
Intro
The Parameters utility provides an AppConfigProvider that allows to retrieve configuration profiles from AWS AppConfig.
Getting started
This utility supports AWS SDK v3 for JavaScript only (
@aws-sdk/client-appconfigdata
). This allows the utility to be modular, and you to install only the SDK packages you need and keep your bundle size small.Basic usage
Example
If you want to retrieve configs without customizing the provider, you can use the getAppConfig function instead.
Advanced usage
Caching
By default, the provider will cache parameters retrieved in-memory for 5 seconds. You can adjust how long values should be kept in cache by using the
maxAge
parameter.Example
If instead you'd like to always ensure you fetch the latest parameter from the store regardless if already available in cache, use the
forceFetch
parameter.Example
Transformations
For configurations stored as freeform JSON, Freature Flag, you can use the transform argument for deserialization. This will return a JavaScript object instead of a string.
Example
For configurations that are instead stored as base64-encoded binary data, you can use the transform argument set to
binary
for decoding. This will return a decoded string.Example
Extra SDK options
When retrieving a configuration profile, you can pass extra options to the AWS SDK v3 for JavaScript client by using the
sdkOptions
parameter.Example
This object accepts the same options as the AWS SDK v3 for JavaScript AppConfigData client.
Customize AWS SDK v3 for JavaScript client
By default, the provider will create a new AppConfigData client using the default configuration.
You can customize the client by passing a custom configuration object to the provider.
Example
This object accepts the same options as the AWS SDK v3 for JavaScript AppConfig Data client.
Otherwise, if you want to use a custom client altogether, you can pass it to the provider.
Example
This object must be an instance of the AWS SDK v3 for JavaScript AppConfig Data client.
For more usage examples, see our documentation.