Skip to content
SSM Parameter Store cache library
Branch: master
Clone or download
Latest commit bcf44f7 May 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
ssm-cache-impl.go
ssm-cache.go Initial Commit May 19, 2018

README.md

ssm-cache

An in memory cache that provides typed accessors to the SSM Parameter Store, inspired by ssm-cache-python.

Usage

Create a Client

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)
}

Fetch Value

Default Expiry

  stringVal, stringValErr := cacheClient.GetString("MyParam")
  stringSliceVal, stringSliceValErr := cacheClient.GetStringList("MyParam")
  decryptedStringVal, decryptedStringValErr := cacheClient.GetSecureString("MyParam")

Custom Expiry

  stringVal, stringValErr := cacheClient.GetExpiringString("MyParam", 30*time.Second)
  stringSliceVal, stringSliceValErr := cacheClient.GetExpiringStringList("MyParam", 30*time.Second)
  decryptedStringVal, decryptedStringValErr := cacheClient.GetExpiringSecureString("MyParam", 30*time.Second)

Force Refresh

Use Purge(keyname) to force delete a cached entry and reload the value from SSM.

  stringVal, stringValErr := cacheClient.Purge("MyParam").GetString("MyParam")

Fetch Group

Default Expiry

  paramMap, paramMapErr := cacheClient.GetParameterGroup("StorageKey", "/my/custom/ssm-path")

Custom Expiry

  paramMap, paramMapErr := cacheClient.GetExpiringParameterGroup("StorageKey", "/my/custom/ssm-path")

References

You can’t perform that action at this time.