Documentation ¶
Overview ¶
Package secretcache provides the Cache struct for in-memory caching of secrets stored in AWS Secrets Manager Also exports a CacheHook, for pre-store and post-fetch processing of cached values
Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- type Cache
- func (c *Cache) GetSecretBinary(secretId string) ([]byte, error)
- func (c *Cache) GetSecretBinaryWithContext(ctx context.Context, secretId string) ([]byte, error)
- func (c *Cache) GetSecretBinaryWithStage(secretId string, versionStage string) ([]byte, error)
- func (c *Cache) GetSecretBinaryWithStageWithContext(ctx context.Context, secretId string, versionStage string) ([]byte, error)
- func (c *Cache) GetSecretString(secretId string) (string, error)
- func (c *Cache) GetSecretStringWithContext(ctx context.Context, secretId string) (string, error)
- func (c *Cache) GetSecretStringWithStage(secretId string, versionStage string) (string, error)
- func (c *Cache) GetSecretStringWithStageWithContext(ctx context.Context, secretId string, versionStage string) (string, error)
- func (c *Cache) RefreshNow(secretId string)
- func (c *Cache) RefreshNowWithContext(ctx context.Context, secretId string)
- type CacheConfig
- type CacheHook
- type InvalidConfigError
- type InvalidOperationError
- type SecretsManagerAPIClient
- type VersionNotFoundError
Constants ¶
const ( DefaultMaxCacheSize = 1024 DefaultCacheItemTTL = 3600000000000 // 1 hour in nanoseconds DefaultVersionStage = "AWSCURRENT" )
const ( VersionNumber = "2" MajorRevisionNumber = "0" MinorRevisionNumber = "2" BugfixRevisionNumber = "0" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { CacheConfig Client SecretsManagerAPIClient // contains filtered or unexported fields }
Cache client for AWS Secrets Manager secrets.
func New ¶
New constructs a secret cache using functional options, uses defaults otherwise. Initialises a SecretsManager Client from a new config.LoadDefaultConfig. Initialises CacheConfig to default values. Initialises lru cache with a default max size.
func (*Cache) GetSecretBinary ¶
GetSecretBinary gets the secret binary value from the cache for given secret id and a default version stage. Returns the secret binary and an error if operation failed.
func (*Cache) GetSecretBinaryWithContext ¶
func (*Cache) GetSecretBinaryWithStage ¶
GetSecretBinaryWithStage gets the secret binary value from the cache for given secret id and version stage. Returns the secret binary and an error if operation failed.
func (*Cache) GetSecretBinaryWithStageWithContext ¶
func (*Cache) GetSecretString ¶
GetSecretString gets the secret string value from the cache for given secret id and a default version stage. Returns the secret string and an error if operation failed.
func (*Cache) GetSecretStringWithContext ¶
func (*Cache) GetSecretStringWithStage ¶
GetSecretStringWithStage gets the secret string value from the cache for given secret id and version stage. Returns the secret string and an error if operation failed.
func (*Cache) GetSecretStringWithStageWithContext ¶
func (*Cache) RefreshNow ¶
Method to force the refresh of a secret inside the cache
type CacheConfig ¶
type CacheConfig struct { //The maximum number of cached secrets to maintain before evicting secrets that //have not been accessed recently. MaxCacheSize int //The number of nanoseconds that a cached item is considered valid before // requiring a refresh of the secret state. Items that have exceeded this // TTL will be refreshed synchronously when requesting the secret value. If // the synchronous refresh failed, the stale secret will be returned. CacheItemTTL int64 //The version stage that will be used when requesting the secret values for //this cache. VersionStage string //Used to hook in-memory cache updates. Hook CacheHook }
CacheConfig is the config object passed to the Cache struct
type CacheHook ¶
type CacheHook interface { // Put prepares the object for storing in the cache. Put(data interface{}) interface{} // Get derives the object from the cached object. Get(data interface{}) interface{} }
CacheHook is an interface to hook into the local in-memory cache. This interface will allow users to perform actions on the items being stored in the in-memory cache. One example would be encrypting/decrypting items stored in the in-memory cache.
type InvalidConfigError ¶
type InvalidConfigError struct {
// contains filtered or unexported fields
}
func (*InvalidConfigError) Error ¶
func (i *InvalidConfigError) Error() string
type InvalidOperationError ¶
type InvalidOperationError struct {
// contains filtered or unexported fields
}
func (*InvalidOperationError) Error ¶
func (i *InvalidOperationError) Error() string
type SecretsManagerAPIClient ¶
type SecretsManagerAPIClient interface { GetSecretValue(ctx context.Context, params *secretsmanager.GetSecretValueInput, optFns ...func(*secretsmanager.Options)) (*secretsmanager.GetSecretValueOutput, error) CreateSecret(ctx context.Context, params *secretsmanager.CreateSecretInput, optFns ...func(*secretsmanager.Options)) (*secretsmanager.CreateSecretOutput, error) DeleteSecret(ctx context.Context, params *secretsmanager.DeleteSecretInput, optFns ...func(*secretsmanager.Options)) (*secretsmanager.DeleteSecretOutput, error) DescribeSecret(ctx context.Context, params *secretsmanager.DescribeSecretInput, optFns ...func(*secretsmanager.Options)) (*secretsmanager.DescribeSecretOutput, error) ListSecrets(ctx context.Context, params *secretsmanager.ListSecretsInput, optFns ...func(*secretsmanager.Options)) (*secretsmanager.ListSecretsOutput, error) UpdateSecret(ctx context.Context, params *secretsmanager.UpdateSecretInput, optFns ...func(*secretsmanager.Options)) (*secretsmanager.UpdateSecretOutput, error) }
type VersionNotFoundError ¶
type VersionNotFoundError struct {
// contains filtered or unexported fields
}
func (*VersionNotFoundError) Error ¶
func (v *VersionNotFoundError) Error() string