For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-alicloud-oss-bucket-lifecycle-disabled.md. A documentation index is available at /llms.txt.
This product is not supported for your selected Datadog site. ().

Metadata

Id: terraform-alicloud-oss-bucket-lifecycle-disabled

Provider: Alicloud

Platform: Terraform

Severity: Low

Category: Backup

Learn More

Description

alicloud_oss_bucket resources should include a lifecycle_rule block with enabled set to true. If the lifecycle_rule block is missing, the policy flags the bucket. If the block exists but enabled is false, the policy flags it and recommends changing enabled from false to true.

Compliant Code Examples

resource "alicloud_oss_bucket" "oss_bucket_lifecycle_enabled1" {
  bucket = "bucket-170309-lifecycle"
  acl    = "public-read"

  lifecycle_rule {
    id      = "rule-days"
    prefix  = "path1/"
    enabled = true

    expiration {
      days = 365
    }
  }
  lifecycle_rule {
    id      = "rule-date"
    prefix  = "path2/"
    enabled = true

    expiration {
      date = "2018-01-12"
    }
  }
}

Non-Compliant Code Examples

resource "alicloud_oss_bucket" "oss_bucket_lifecycle_enabled2" {
  bucket = "bucket-170309-lifecycle"
  acl    = "public-read"

  lifecycle_rule {
    id      = "rule-days"
    prefix  = "path1/"
    enabled = false

    expiration {
      days = 365
    }
  }
  lifecycle_rule {
    id      = "rule-date"
    prefix  = "path2/"
    enabled = true

    expiration {
      date = "2018-01-12"
    }
  }
}
resource "alicloud_oss_bucket" "oss_bucket_lifecycle_enabled3" {
  bucket = "bucket-170309-versioning"
  acl    = "private"

  versioning {
    status = "Enabled"
  }
}