Alicloud OSS bucket has no access logging

Retain access records for the bucket and its objects.

Description

OSS access logs record requests to a bucket and its objects.

Potential impact

Missing records make it harder to trace an unexpected change or diagnose a failed request.

Remediation

Point logging.target_bucket to a separate bucket in the same account and region. Set target_prefix, log access and retention. Make a test request and look for its record under that prefix. OSS ships logs hourly, but delivery can take up to 48 hours.

Examples

The second excerpt sends logs to bucket_target under log/. Check the source bucket’s ACL separately if it should be private.

Before

hcl
resource "alicloud_oss_bucket" "bucket" {
  bucket = "bucket-170309-acl"
  acl    = "public-read"
}

After

hcl
resource "alicloud_oss_bucket" "bucket" {
  bucket = "bucket-170309-acl"

  logging {
    target_bucket = alicloud_oss_bucket.bucket_target.id
    target_prefix = "log/"
  }
}

References