Class SSMProvider
java.lang.Object
software.amazon.lambda.powertools.parameters.BaseProvider
software.amazon.lambda.powertools.parameters.ssm.SSMProvider
- All Implemented Interfaces:
ParamProvider
AWS System Manager Parameter Store Provider
Samples:
Samples:
SSMProvider provider = SSMProvider.builder().build();
String value = provider.get("key");
System.out.println(value);
>>> "value"
// Get a value and cache it for 30 seconds (all others values will now be cached for 30 seconds)
String value = provider.defaultMaxAge(30, ChronoUnit.SECONDS).get("key");
// Get a value and cache it for 1 minute (all others values are cached for 5 seconds by default)
String value = provider.withMaxAge(1, ChronoUnit.MINUTES).get("key");
// Get a base64 encoded value, decoded into a String, and store it in the cache
String value = provider.withTransformation(Transformer.base64).get("key");
// Get a json value, transform it into an Object, and store it in the cache
TargetObject = provider.withTransformation(Transformer.json).get("key", TargetObject.class);
// Get a decrypted value, and store it in the cache
String value = provider.withDecryption().get("key");
// Get multiple parameter values starting with the same path
Mapinvalid input: '<'String, String> params = provider.getMultiple("/path/to/paramters");
>>> /path/to/parameters/key1 -> value1
>>> /path/to/parameters/key2 -> value2
// Get multiple parameter values starting with the same path and recursively
Mapinvalid input: '<'String, String> params = provider.recursive().getMultiple("/path/to/paramters");
>>> /path/to/parameters/key1 -> value1
>>> /path/to/parameters/key2 -> value2
>>> /path/to/parameters/others/key3 -> value3
-
Field Summary
Fields inherited from class software.amazon.lambda.powertools.parameters.BaseProvider
cacheManager, PARAMETERS -
Method Summary
Modifier and TypeMethodDescriptionstatic SSMProviderBuilderbuilder()Create a builder that can be used to configure and create aSSMProvider.static SSMProvidercreate()Create a SSMProvider with all default settings.getMultipleValues(String path) Retrieve multiple parameter values from AWS System Manager Parameter Store.
Retrieve all parameters starting with the path provided in parameter.
eg. getMultiple("/foo/bar") will retrieve /foo/bar/baz, foo/bar/biz
Usingrecursive(), getMultiple("/foo/bar") will retrieve /foo/bar/baz, foo/bar/biz and foo/bar/buz/boz
Cache all values with the 'path' as the key and also individually to be able toBaseProvider.get(String)a single value later
Does not support transformation.Retrieve the parameter value from the AWS System Manager Parameter Store.Tells System Manager Parameter Store to retrieve all parameters starting with a path (all levels)
Only used withBaseProvider.getMultiple(String).protected voidTells System Manager Parameter Store to decrypt the parameter value.
By default, parameter values are not decrypted.
Valid both for get and getMultiple.Methods inherited from class software.amazon.lambda.powertools.parameters.BaseProvider
get, get, getMultiple, now, withMaxAge, withTransformation
-
Method Details
-
builder
Create a builder that can be used to configure and create aSSMProvider.- Returns:
- a new instance of
SSMProviderBuilder
-
create
Create a SSMProvider with all default settings. -
getValue
Retrieve the parameter value from the AWS System Manager Parameter Store.- Specified by:
getValuein classBaseProvider- Parameters:
key- key of the parameter- Returns:
- the value of the parameter identified by the key
-
withDecryption
Tells System Manager Parameter Store to decrypt the parameter value.
By default, parameter values are not decrypted.
Valid both for get and getMultiple.- Returns:
- the provider itself in order to chain calls (eg.
provider.withDecryption().get("key")).
-
recursive
Tells System Manager Parameter Store to retrieve all parameters starting with a path (all levels)
Only used withBaseProvider.getMultiple(String).- Returns:
- the provider itself in order to chain calls (eg.
provider.recursive().getMultiple("key")).
-
getMultipleValues
Retrieve multiple parameter values from AWS System Manager Parameter Store.
Retrieve all parameters starting with the path provided in parameter.
eg. getMultiple("/foo/bar") will retrieve /foo/bar/baz, foo/bar/biz
Usingrecursive(), getMultiple("/foo/bar") will retrieve /foo/bar/baz, foo/bar/biz and foo/bar/buz/boz
Cache all values with the 'path' as the key and also individually to be able toBaseProvider.get(String)a single value later
Does not support transformation.- Specified by:
getMultipleValuesin classBaseProvider- Parameters:
path- path of the parameter- Returns:
- a map containing parameters keys and values. The key is a subpart of the path
eg. getMultiple("/foo/bar") will retrieve [key="baz", value="valuebaz"] for parameter "/foo/bar/baz"
-
resetToDefaults
protected void resetToDefaults()- Overrides:
resetToDefaultsin classBaseProvider
-