Class CachableSecretsManager


  • public class CachableSecretsManager
    extends Object
    Since Athena may call your connector or UDF at a high TPS or concurrency you may want to have a short lived cache in front of SecretsManager to avoid bottlenecking on SecretsManager. This class offers such a cache. This class also has utilities for idetifying and replacing secrets in scripts. For example: MyString${WithSecret} would have ${WithSecret} replaced by the corresponding value of the secret in AWS Secrets Manager with that name.
    • Constructor Detail

      • CachableSecretsManager

        public CachableSecretsManager​(com.amazonaws.services.secretsmanager.AWSSecretsManager secretsManager)
    • Method Detail

      • resolveSecrets

        public String resolveSecrets​(String rawString)
        Resolves any secrets found in the supplied string, for example: MyString${WithSecret} would have ${WithSecret} repalced by the corresponding value of the secret in AWS Secrets Manager with that name. If no such secret is found the function throws.
        Parameters:
        rawString - The string in which to find and replace/inject secrets.
        Returns:
        The processed rawString that has had all secrets replaced with their secret value from SecretsManager. Throws if any of the secrets can not be found.
      • getSecret

        public String getSecret​(String secretName)
        Retrieves a secret from SecretsManager, first checking the cache. Newly fetched secrets are added to the cache.
        Parameters:
        secretName - The name of the secret to retrieve.
        Returns:
        The value of the secret, throws if no such secret is found.
      • addCacheEntry

        protected void addCacheEntry​(String name,
                                     String value,
                                     long createTime)