Class AwsSecretsManagerConfig.Builder
java.lang.Object
codes.grow.packages.awssecretsmanager.AwsSecretsManagerConfig.Builder
- Enclosing class:
AwsSecretsManagerConfig
Builder of the configuration.
Fields that are not set explicitly take the environment (when fromEnv(EnvReader)
was called, in any order) or the default.
-
Method Summary
Modifier and TypeMethodDescriptionaccessKeyId(String accessKeyId) Sets the static access key id (requiressecretAccessKey(String)).build()Builds and validates the configuration.Sets the connect timeout (default 10 s).credentials(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentials) Uses an AWS SDK credentials provider instead of the key fields or the default chain.externalId(String externalId) Sets the STS external id.Fills every field that is not set explicitly from the environment whenbuild()runs:GROW_AWS_SECRETS_MANAGER_*first, then the standard AWS variables.Adds a header sent with every request.Sets request hooks.Sets the logger (default silent).Selects a shared config / credentials profile.Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.recoveryWindowDays(int days) Sets the recovery window of deletes in days (7–30, default 30).Sets the AWS region.Sets the per-attempt timeout (default 30 s).retry(RetryPolicy retry) Sets the retry policy (defaultRetryPolicy.defaults()).Assumes this IAM role with STS on top of the base credentials.roleDuration(Duration duration) Sets the assumed-role session duration (900 s – 43 200 s; default: the role's default).roleSessionName(String name) Sets the STS role session name (default "grow-sdk").sdkClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient sdkClient) Wraps an existing AWS SDK client instead of building one.secretAccessKey(Secret secretAccessKey) Sets the static secret access key.secretAccessKey(String secretAccessKey) Sets the static secret access key.sessionToken(Secret sessionToken) Sets the session token of temporary credentials.sessionToken(String sessionToken) Sets the session token of temporary credentials.tls(TlsOptions tls) Sets the TLS options; environment TLS variables are then ignored.Sets the total timeout per call including retries (default 120 s).Sets the endpoint override, e.g.userAgentSuffix(String suffix) Sets the text appended to theUser-Agent.
-
Method Details
-
fromEnv
Fills every field that is not set explicitly from the environment whenbuild()runs:GROW_AWS_SECRETS_MANAGER_*first, then the standard AWS variables. The key id, secret key and session token are taken as one set from one layer (aGROW_*key id never pairs with anAWS_*secret). With an explicitsdkClientorcredentials, credentials from the environment are ignored; withsdkClientalso the region, endpoint, profile and role.- Parameters:
env- environment reader- Returns:
- this builder
-
url
Sets the endpoint override, e.g.http://localhost:5000for an emulator. Unset: the AWS SDK resolveshttps://secretsmanager.<region>.amazonaws.com.- Parameters:
url-httporhttpsURL- Returns:
- this builder
-
connectTimeout
Sets the connect timeout (default 10 s).- Parameters:
d- positive duration- Returns:
- this builder
-
requestTimeout
Sets the per-attempt timeout (default 30 s).- Parameters:
d- positive duration- Returns:
- this builder
-
totalTimeout
Sets the total timeout per call including retries (default 120 s).- Parameters:
d- positive duration- Returns:
- this builder
-
retry
Sets the retry policy (defaultRetryPolicy.defaults()).- Parameters:
retry- policy- Returns:
- this builder
-
tls
Sets the TLS options; environment TLS variables are then ignored.- Parameters:
tls- options- Returns:
- this builder
-
proxy
Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.- Parameters:
proxy- proxy URL- Returns:
- this builder
-
header
Adds a header sent with every request.- Parameters:
name- header namevalue- header value- Returns:
- this builder
-
userAgentSuffix
Sets the text appended to theUser-Agent.- Parameters:
suffix- suffix- Returns:
- this builder
-
hooks
Sets request hooks.- Parameters:
hooks- hooks- Returns:
- this builder
-
logger
Sets the logger (default silent).- Parameters:
logger- logger- Returns:
- this builder
-
region
Sets the AWS region.- Parameters:
region- region such aseu-central-1- Returns:
- this builder
-
accessKeyId
Sets the static access key id (requiressecretAccessKey(String)).- Parameters:
accessKeyId- key id- Returns:
- this builder
-
secretAccessKey
Sets the static secret access key.- Parameters:
secretAccessKey- key- Returns:
- this builder
-
secretAccessKey
Sets the static secret access key.- Parameters:
secretAccessKey- key- Returns:
- this builder
-
sessionToken
Sets the session token of temporary credentials.- Parameters:
sessionToken- token- Returns:
- this builder
-
sessionToken
Sets the session token of temporary credentials.- Parameters:
sessionToken- token- Returns:
- this builder
-
profile
Selects a shared config / credentials profile.- Parameters:
profile- profile name- Returns:
- this builder
-
credentials
public AwsSecretsManagerConfig.Builder credentials(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider credentials) Uses an AWS SDK credentials provider instead of the key fields or the default chain.- Parameters:
credentials- provider- Returns:
- this builder
-
roleArn
Assumes this IAM role with STS on top of the base credentials.- Parameters:
roleArn- role ARN- Returns:
- this builder
-
roleSessionName
Sets the STS role session name (default "grow-sdk").- Parameters:
name- session name- Returns:
- this builder
-
externalId
Sets the STS external id.- Parameters:
externalId- external id- Returns:
- this builder
-
roleDuration
Sets the assumed-role session duration (900 s – 43 200 s; default: the role's default).- Parameters:
duration- duration- Returns:
- this builder
-
recoveryWindowDays
Sets the recovery window of deletes in days (7–30, default 30).- Parameters:
days- window- Returns:
- this builder
-
sdkClient
public AwsSecretsManagerConfig.Builder sdkClient(software.amazon.awssdk.services.secretsmanager.SecretsManagerClient sdkClient) Wraps an existing AWS SDK client instead of building one. Mutually exclusive with the credential, region, profile, role and endpoint fields;close()never closes it and the Grow timeouts, retries, TLS, proxy, headers, hooks and User-Agent do not apply to it.- Parameters:
sdkClient- the client- Returns:
- this builder
-
build
Builds and validates the configuration.- Returns:
- the configuration
- Throws:
ConfigException- when a rule is violated
-