Class AwsSecretsManagerConfig

java.lang.Object
codes.grow.packages.awssecretsmanager.AwsSecretsManagerConfig

public final class AwsSecretsManagerConfig extends Object
Immutable configuration of a AwsSecretsManagerClient (SPEC section 2.2 plus the AWS fields of API.md section 5).

Build one with builder() or read it from the environment with fromEnv(). Precedence: explicit builder value > GROW_AWS_SECRETS_MANAGER_<NAME> > the standard AWS variables (AWS_REGION, AWS_ACCESS_KEY_ID, AWS_ENDPOINT_URL_SECRETS_MANAGER, ...) > defaults. Credentials left unset use the AWS SDK default credential chain. toString() never prints credentials.

  • Field Details

    • DEFAULT_RECOVERY_WINDOW_DAYS

      public static final int DEFAULT_RECOVERY_WINDOW_DAYS
      Default recovery window of deletes in days (the AWS default).
      See Also:
    • DEFAULT_ROLE_SESSION_NAME

      public static final String DEFAULT_ROLE_SESSION_NAME
      Default STS role session name of the assume-role helper.
      See Also:
  • Method Details

    • builder

      public static AwsSecretsManagerConfig.Builder builder()
      Starts an empty builder (every field at its default).
      Returns:
      a new builder
    • fromEnv

      public static AwsSecretsManagerConfig fromEnv()
      Reads the configuration from the process environment.
      Returns:
      the validated configuration
      Throws:
      ConfigException - when a variable holds an invalid value (the message names the variable, never the value)
    • fromEnv

      public static AwsSecretsManagerConfig fromEnv(Map<String,String> env)
      Reads the configuration from an explicit variable map (tests).
      Parameters:
      env - variable map
      Returns:
      the validated configuration
    • validate

      public void validate()
      Checks every rule: URL scheme, positive timeouts, TLS pairs, region format, credential pairs, exclusive options, role ARN and duration, recovery window.
      Throws:
      ConfigException - listing every violated rule
    • url

      public String url()
      Returns the effective endpoint: the override when set, otherwise the public AWS endpoint of the region (us-east-1 when the region is left to the SDK). Informational.
      Returns:
      the URL
    • endpoint

      public Optional<String> endpoint()
      Returns the explicit endpoint override passed to the AWS SDK.
      Returns:
      the endpoint, or empty when the SDK resolves it
    • connectTimeout

      public Duration connectTimeout()
      Returns the connect timeout (default 10 s).
      Returns:
      the timeout
    • requestTimeout

      public Duration requestTimeout()
      Returns the per-attempt timeout (default 30 s).
      Returns:
      the timeout
    • totalTimeout

      public Duration totalTimeout()
      Returns the total timeout per call including retries (default 120 s).
      Returns:
      the timeout
    • retry

      public RetryPolicy retry()
      Returns the retry policy; the AWS SDK standard retry strategy uses maxRetries + 1 attempts and the policy's backoff bounds.
      Returns:
      the policy
    • tls

      public TlsOptions tls()
      Returns the TLS options.
      Returns:
      the options
    • proxy

      public Optional<String> proxy()
      Returns the explicit proxy URL.
      Returns:
      the proxy, or empty
    • headers

      public Map<String,String> headers()
      Returns the extra request headers.
      Returns:
      immutable map
    • userAgentSuffix

      public Optional<String> userAgentSuffix()
      Returns the text appended to the User-Agent.
      Returns:
      the suffix, or empty
    • hooks

      public Hooks hooks()
      Returns the hooks.
      Returns:
      the hooks
    • logger

      public Logger logger()
      Returns the logger (silent by default).
      Returns:
      the logger
    • region

      public Optional<String> region()
      Returns the AWS region.
      Returns:
      the region, or empty when the SDK chain (environment, shared config) decides
    • accessKeyId

      public Optional<String> accessKeyId()
      Returns the static access key id.
      Returns:
      the key id, or empty
    • secretAccessKey

      public Optional<Secret> secretAccessKey()
      Returns the static secret access key.
      Returns:
      the key, or empty
    • sessionToken

      public Optional<Secret> sessionToken()
      Returns the session token of temporary credentials.
      Returns:
      the token, or empty
    • profile

      public Optional<String> profile()
      Returns the shared config profile.
      Returns:
      the profile, or empty
    • credentials

      public Optional<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider> credentials()
      Returns the explicit AWS SDK credentials provider.
      Returns:
      the provider, or empty
    • roleArn

      public Optional<String> roleArn()
      Returns the IAM role assumed with STS on top of the base credentials.
      Returns:
      the role ARN, or empty
    • roleSessionName

      public String roleSessionName()
      Returns the STS role session name (default "grow-sdk").
      Returns:
      the session name
    • externalId

      public Optional<String> externalId()
      Returns the STS external id.
      Returns:
      the external id, or empty
    • roleDuration

      public Optional<Duration> roleDuration()
      Returns the assumed-role session duration.
      Returns:
      the duration, or empty for the role's default
    • recoveryWindowDays

      public int recoveryWindowDays()
      Returns the recovery window of deletes in days (7–30, default 30).
      Returns:
      the window
    • sdkClient

      public Optional<software.amazon.awssdk.services.secretsmanager.SecretsManagerClient> sdkClient()
      Returns the caller-supplied AWS SDK client.
      Returns:
      the client, or empty when the package builds its own
    • knownSecrets

      public List<String> knownSecrets()
      Returns the credential values that must never appear in messages or logs.
      Returns:
      the known secret values
    • toString

      public String toString()
      Overrides:
      toString in class Object