Class CloudWatchLogsConfig.Builder
java.lang.Object
codes.grow.packages.cloudwatchlogs.CloudWatchLogsConfig.Builder
- Enclosing class:
CloudWatchLogsConfig
Builder of the configuration.
Unset fields take the environment (when fromEnv(EnvReader) is called) or the
default.
-
Method Summary
Modifier and TypeMethodDescriptionaccessKeyId(String accessKeyId) Sets the access key id.Sets the AWS account id used for live-tail ARNs.autoCreate(boolean autoCreate) Sets whetherputLogEventscreates a missing log stream and retries once.build()Builds and validates the configuration.Sets the connect timeout (default 10 s).credentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider provider) Sets 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 was not set explicitly from the environment.Adds a header sent with every request.Sets request hooks (fired once per HTTP attempt).Sets the logger (default silent).Sets the default log group.Sets the log stream of the log client.maxEventBytes(int bytes) Sets the per-event message limit (64 to 1 048 550 bytes; default 262 144).oversizePolicy(OversizePolicy policy) Sets the policy for oversized events.Sets the shared config profile.Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.Sets the AWS region.Sets the per-attempt timeout (default 30 s; not applied to live-tail sessions).retry(RetryPolicy retry) Sets the retry policy (defaultRetryPolicy.defaults()).Sets a role assumed with STS on top of the base credentials.roleSessionName(String name) Sets the STS session name (defaultgrow-sdk).sdkClient(software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClient client) Uses an existing AWS SDK async client instead of building one.secretAccessKey(Secret secret) Sets the secret access key.secretAccessKey(String secret) Sets the secret access key.sessionToken(Secret token) Sets the session token.sessionToken(String token) Sets the session token.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 (http://aws-cloudwatch-logs:5000in Docker).userAgentSuffix(String suffix) Sets the text appended to theUser-Agent.
-
Method Details
-
fromEnv
Fills every field that was not set explicitly from the environment. An explicitsdkClientorcredentialsProviderreplaces the credentials of the environment (and an explicitsdkClientalso its region, endpoint, profile and role). Credentials come from one layer: aGROW_…_ACCESS_KEY_IDnever pairs with anAWS_SECRET_ACCESS_KEY.- Parameters:
env- environment reader- Returns:
- this builder
- Throws:
ConfigException- when a variable holds an invalid value
-
url
Sets the endpoint override (http://aws-cloudwatch-logs:5000in Docker). Unset: the AWS SDK resolveshttps://logs.<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; not applied to live-tail sessions).- 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 (fired once per HTTP attempt).- 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 asus-east-1- Returns:
- this builder
-
accessKeyId
Sets the access key id.- Parameters:
accessKeyId- key id- Returns:
- this builder
-
secretAccessKey
Sets the secret access key.- Parameters:
secret- secret- Returns:
- this builder
-
secretAccessKey
Sets the secret access key.- Parameters:
secret- secret- Returns:
- this builder
-
sessionToken
Sets the session token.- Parameters:
token- token- Returns:
- this builder
-
sessionToken
Sets the session token.- Parameters:
token- token- Returns:
- this builder
-
profile
Sets the shared config profile.- Parameters:
profile- profile name- Returns:
- this builder
-
credentialsProvider
public CloudWatchLogsConfig.Builder credentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider provider) Sets an AWS SDK credentials provider (instead of the key fields or the default chain).- Parameters:
provider- provider- Returns:
- this builder
-
roleArn
Sets a role assumed with STS on top of the base credentials.- Parameters:
roleArn- role ARN- Returns:
- this builder
-
roleSessionName
Sets the STS session name (defaultgrow-sdk).- Parameters:
name- session name- Returns:
- this builder
-
externalId
Sets the STS external id.- Parameters:
externalId- external id- Returns:
- this builder
-
logGroup
Sets the default log group.- Parameters:
logGroup- group name- Returns:
- this builder
-
logStream
Sets the log stream of the log client.- Parameters:
logStream- stream name- Returns:
- this builder
-
accountId
Sets the AWS account id used for live-tail ARNs.- Parameters:
accountId- 12-digit account id- Returns:
- this builder
-
maxEventBytes
Sets the per-event message limit (64 to 1 048 550 bytes; default 262 144).- Parameters:
bytes- limit in UTF-8 bytes- Returns:
- this builder
-
oversizePolicy
Sets the policy for oversized events.- Parameters:
policy- policy- Returns:
- this builder
-
autoCreate
Sets whetherputLogEventscreates a missing log stream and retries once.- Parameters:
autoCreate- flag (default true)- Returns:
- this builder
-
sdkClient
public CloudWatchLogsConfig.Builder sdkClient(software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsAsyncClient client) Uses an existing AWS SDK async client instead of building one. Mutually exclusive with the credential, region and endpoint fields;close()never closes it and the Grow hooks, TLS, proxy, timeout and User-Agent settings do not apply to it.- Parameters:
client- the SDK client- Returns:
- this builder
-
build
Builds and validates the configuration.- Returns:
- the configuration
- Throws:
ConfigException- when a rule is violated
-