Class CloudWatchLogsConfig.Builder

java.lang.Object
codes.grow.packages.cloudwatchlogs.CloudWatchLogsConfig.Builder
Enclosing class:
CloudWatchLogsConfig

public static final class CloudWatchLogsConfig.Builder extends Object
Builder of the configuration.

Unset fields take the environment (when fromEnv(EnvReader) is called) or the default.

  • Method Details

    • fromEnv

      Fills every field that was not set explicitly from the environment. An explicit sdkClient or credentialsProvider replaces the credentials of the environment (and an explicit sdkClient also its region, endpoint, profile and role). Credentials come from one layer: a GROW_…_ACCESS_KEY_ID never pairs with an AWS_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:5000 in Docker). Unset: the AWS SDK resolves https://logs.<region>.amazonaws.com.
      Parameters:
      url - http or https URL
      Returns:
      this builder
    • connectTimeout

      public CloudWatchLogsConfig.Builder connectTimeout(Duration d)
      Sets the connect timeout (default 10 s).
      Parameters:
      d - positive duration
      Returns:
      this builder
    • requestTimeout

      public CloudWatchLogsConfig.Builder requestTimeout(Duration d)
      Sets the per-attempt timeout (default 30 s; not applied to live-tail sessions).
      Parameters:
      d - positive duration
      Returns:
      this builder
    • totalTimeout

      public CloudWatchLogsConfig.Builder totalTimeout(Duration d)
      Sets the total timeout per call including retries (default 120 s).
      Parameters:
      d - positive duration
      Returns:
      this builder
    • retry

      Sets the retry policy (default RetryPolicy.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

      public CloudWatchLogsConfig.Builder proxy(String proxy)
      Sets an explicit proxy URL; environment proxies (HTTPS_PROXY) are never used.
      Parameters:
      proxy - proxy URL
      Returns:
      this builder
    • header

      public CloudWatchLogsConfig.Builder header(String name, String value)
      Adds a header sent with every request.
      Parameters:
      name - header name
      value - header value
      Returns:
      this builder
    • userAgentSuffix

      public CloudWatchLogsConfig.Builder userAgentSuffix(String suffix)
      Sets the text appended to the User-Agent.
      Parameters:
      suffix - suffix
      Returns:
      this builder
    • hooks

      public CloudWatchLogsConfig.Builder hooks(Hooks hooks)
      Sets request hooks (fired once per HTTP attempt).
      Parameters:
      hooks - hooks
      Returns:
      this builder
    • logger

      public CloudWatchLogsConfig.Builder logger(Logger logger)
      Sets the logger (default silent).
      Parameters:
      logger - logger
      Returns:
      this builder
    • region

      public CloudWatchLogsConfig.Builder region(String region)
      Sets the AWS region.
      Parameters:
      region - region such as us-east-1
      Returns:
      this builder
    • accessKeyId

      public CloudWatchLogsConfig.Builder accessKeyId(String accessKeyId)
      Sets the access key id.
      Parameters:
      accessKeyId - key id
      Returns:
      this builder
    • secretAccessKey

      public CloudWatchLogsConfig.Builder secretAccessKey(Secret secret)
      Sets the secret access key.
      Parameters:
      secret - secret
      Returns:
      this builder
    • secretAccessKey

      public CloudWatchLogsConfig.Builder secretAccessKey(String secret)
      Sets the secret access key.
      Parameters:
      secret - secret
      Returns:
      this builder
    • sessionToken

      public CloudWatchLogsConfig.Builder sessionToken(Secret token)
      Sets the session token.
      Parameters:
      token - token
      Returns:
      this builder
    • sessionToken

      public CloudWatchLogsConfig.Builder sessionToken(String token)
      Sets the session token.
      Parameters:
      token - token
      Returns:
      this builder
    • profile

      public CloudWatchLogsConfig.Builder profile(String 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

      public CloudWatchLogsConfig.Builder roleArn(String roleArn)
      Sets a role assumed with STS on top of the base credentials.
      Parameters:
      roleArn - role ARN
      Returns:
      this builder
    • roleSessionName

      public CloudWatchLogsConfig.Builder roleSessionName(String name)
      Sets the STS session name (default grow-sdk).
      Parameters:
      name - session name
      Returns:
      this builder
    • externalId

      public CloudWatchLogsConfig.Builder externalId(String externalId)
      Sets the STS external id.
      Parameters:
      externalId - external id
      Returns:
      this builder
    • logGroup

      public CloudWatchLogsConfig.Builder logGroup(String logGroup)
      Sets the default log group.
      Parameters:
      logGroup - group name
      Returns:
      this builder
    • logStream

      public CloudWatchLogsConfig.Builder logStream(String logStream)
      Sets the log stream of the log client.
      Parameters:
      logStream - stream name
      Returns:
      this builder
    • accountId

      public CloudWatchLogsConfig.Builder accountId(String accountId)
      Sets the AWS account id used for live-tail ARNs.
      Parameters:
      accountId - 12-digit account id
      Returns:
      this builder
    • maxEventBytes

      public CloudWatchLogsConfig.Builder maxEventBytes(int bytes)
      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

      public CloudWatchLogsConfig.Builder oversizePolicy(OversizePolicy policy)
      Sets the policy for oversized events.
      Parameters:
      policy - policy
      Returns:
      this builder
    • autoCreate

      public CloudWatchLogsConfig.Builder autoCreate(boolean autoCreate)
      Sets whether putLogEvents creates 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

      public CloudWatchLogsConfig build()
      Builds and validates the configuration.
      Returns:
      the configuration
      Throws:
      ConfigException - when a rule is violated