Carina

Resource

aws.s3.BucketLogging

Example

let caller = read aws.sts.CallerIdentity {}

let source_bucket = aws.s3.Bucket {
  bucket = 'carina-example-logging-source'

  tags = {
    Environment = 'example'
  }
}

let log_bucket = aws.s3.Bucket {
  bucket = 'carina-example-logging-destination'

  tags = {
    Environment = 'example'
  }
}

let log_bucket_policy = aws.s3.BucketPolicy {
  bucket = log_bucket.bucket

  policy = {
    version = aws.iam.PolicyDocument.Version.2012_10_17
    statement {
      sid    = 'AllowS3LogDelivery'
      effect = aws.iam.PolicyDocument.Statement.Effect.allow

      principal = {
        service = 'logging.s3.amazonaws.com'
      }

      action   = 's3:PutObject'
      resource = ["${log_bucket.arn}/access-logs/*"]

      condition = {
        arn_like      = {
          'aws:SourceArn' = source_bucket.arn
        }
        string_equals = {
          'aws:SourceAccount' = caller.account_id
        }
      }
    }
  }
}

aws.s3.BucketLogging {
  bucket        = source_bucket.bucket
  target_bucket = log_bucket_policy.bucket
  target_prefix = 'access-logs/'
}

Argument Reference

bucket

The name of the bucket for which to set the logging parameters.

target_bucket

Destination bucket for server access logs.

target_prefix

Key prefix to apply to log objects.

target_object_key_format

Partitioning / simple-prefix selector for log object keys.

Enum Values

target_object_key_format.partitioned_prefix.partition_date_source (PartitionDateSource)

Value DSL Identifier
EventTime aws.s3.BucketLogging.TargetObjectKeyFormat.PartitionedPrefix.PartitionDateSource.event_time
DeliveryTime aws.s3.BucketLogging.TargetObjectKeyFormat.PartitionedPrefix.PartitionDateSource.delivery_time

Shorthand formats: event_time or PartitionDateSource.event_time

Struct Definitions

target_object_key_format

Field Type Required Description
simple_prefix Struct(SimplePrefix) No
partitioned_prefix Struct(PartitionedPrefix) No

target_object_key_format.partitioned_prefix

Field Type Required Description
partition_date_source PartitionDateSource No

target_object_key_format.simple_prefix

Field Type Required Description