An in memory cache that provides typed accessors to the SSM Parameter Store, inspired by ssm-cache-python.
Create a single ssmcache.Client instance for your
lambda application. This client should only
be initialized once as part of an init()
function.
The single argument is the default expiry for cached values. To create a cache whose elements do not expire by default, provide the NoExpiration value.
var cacheClient ssmcache.Client
func init() {
cacheClient = ssmcache.NewClient(5 * time.Minute)
}
stringVal, stringValErr := cacheClient.GetString("MyParam")
stringSliceVal, stringSliceValErr := cacheClient.GetStringList("MyParam")
decryptedStringVal, decryptedStringValErr := cacheClient.GetSecureString("MyParam")
stringVal, stringValErr := cacheClient.GetExpiringString("MyParam", 30*time.Second)
stringSliceVal, stringSliceValErr := cacheClient.GetExpiringStringList("MyParam", 30*time.Second)
decryptedStringVal, decryptedStringValErr := cacheClient.GetExpiringSecureString("MyParam", 30*time.Second)
Use Purge(keyname)
to force delete a cached entry and reload the value from SSM.
stringVal, stringValErr := cacheClient.Purge("MyParam").GetString("MyParam")
paramMap, paramMapErr := cacheClient.GetParameterGroup("StorageKey", "/my/custom/ssm-path")
paramMap, paramMapErr := cacheClient.GetExpiringParameterGroup("StorageKey", "/my/custom/ssm-path")