Class LogGroup.Builder

java.lang.Object
software.amazon.awscdk.services.logs.LogGroup.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<LogGroup>
Enclosing class:
LogGroup

@Stability(Stable) public static final class LogGroup.Builder extends Object implements software.amazon.jsii.Builder<LogGroup>
A fluent builder for LogGroup.
  • Method Details

    • create

      @Stability(Stable) public static LogGroup.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of LogGroup.Builder.
    • dataProtectionPolicy

      @Stability(Stable) public LogGroup.Builder dataProtectionPolicy(DataProtectionPolicy dataProtectionPolicy)
      Data Protection Policy for this log group.

      Default: - no data protection policy

      Parameters:
      dataProtectionPolicy - Data Protection Policy for this log group. This parameter is required.
      Returns:
      this
    • deletionProtectionEnabled

      @Stability(Stable) public LogGroup.Builder deletionProtectionEnabled(Boolean deletionProtectionEnabled)
      Indicates whether deletion protection is enabled for this log group.

      When enabled, deletion protection blocks all deletion operations until it is explicitly disabled.

      Default: false

      Parameters:
      deletionProtectionEnabled - Indicates whether deletion protection is enabled for this log group. This parameter is required.
      Returns:
      this
    • encryptionKey

      @Stability(Stable) public LogGroup.Builder encryptionKey(IKeyRef encryptionKey)
      The KMS customer managed key to encrypt the log group with.

      Default: Server-side encryption managed by the CloudWatch Logs service

      Parameters:
      encryptionKey - The KMS customer managed key to encrypt the log group with. This parameter is required.
      Returns:
      this
    • fieldIndexPolicies

      @Stability(Stable) public LogGroup.Builder fieldIndexPolicies(List<? extends FieldIndexPolicy> fieldIndexPolicies)
      Field Index Policies for this log group.

      Default: - no field index policies for this log group.

      Parameters:
      fieldIndexPolicies - Field Index Policies for this log group. This parameter is required.
      Returns:
      this
    • logGroupClass

      @Stability(Stable) public LogGroup.Builder logGroupClass(LogGroupClass logGroupClass)
      The class of the log group. Possible values are: STANDARD, INFREQUENT_ACCESS and DELIVERY.

      INFREQUENT_ACCESS class provides customers a cost-effective way to consolidate logs which supports querying using Logs Insights. The logGroupClass property cannot be changed once the log group is created.

      DELIVERY class is used to deliver logs to a destination such as Amazon S3 or Amazon Data Firehose (for example, Lambda vended logs). A Delivery log group forwards events to a destination instead of storing them, so it does not support retention, dataProtectionPolicy, or fieldIndexPolicies; setting any of these together with LogGroupClass.DELIVERY results in a synthesis-time error.

      Default: LogGroupClass.STANDARD

      Parameters:
      logGroupClass - The class of the log group. Possible values are: STANDARD, INFREQUENT_ACCESS and DELIVERY. This parameter is required.
      Returns:
      this
    • logGroupName

      @Stability(Stable) public LogGroup.Builder logGroupName(String logGroupName)
      Name of the log group.

      Default: Automatically generated

      Parameters:
      logGroupName - Name of the log group. This parameter is required.
      Returns:
      this
    • removalPolicy

      @Stability(Stable) public LogGroup.Builder removalPolicy(RemovalPolicy removalPolicy)
      Determine the removal policy of this log group.

      Normally you want to retain the log group so you can diagnose issues from logs even after a deployment that no longer includes the log group. In that case, use the normal date-based retention policy to age out your logs.

      Default: RemovalPolicy.Retain

      Parameters:
      removalPolicy - Determine the removal policy of this log group. This parameter is required.
      Returns:
      this
    • retention

      @Stability(Stable) public LogGroup.Builder retention(RetentionDays retention)
      How long, in days, the log contents will be retained.

      To retain all logs, set this value to RetentionDays.INFINITE.

      Default: RetentionDays.TWO_YEARS

      Parameters:
      retention - How long, in days, the log contents will be retained. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public LogGroup build()
      Specified by:
      build in interface software.amazon.jsii.Builder<LogGroup>
      Returns:
      a newly built instance of LogGroup.