Skip to content

frostmoln_bucket_lifecycle_configuration (Resource) ​

Manages the lifecycle configuration of an object storage bucket: rules that expire objects, expire noncurrent versions, and abort incomplete multipart uploads on a schedule.

There is no storage-class transition rule and no per-object-tag filter: objects are not moved between storage classes on a schedule, and the lifecycle API does not model tag filters. Neither is offered here, so scope a rule with prefix.

REPLACE SEMANTICS: a bucket carries a single lifecycle configuration and applying this resource replaces it whole.

DO NOT MANAGE THE SAME BUCKET BOTH HERE AND OVER S3. A rule created with your own S3 credentials using a feature this API does not model — a tag filter, a date-based expiry, an object-size filter — is read back WITHOUT that feature, and Terraform then rewrites it stripped. For a rule that expires objects, losing its filter means the rewritten rule DELETES EVERY OBJECT IN THE BUCKET on the schedule that was meant for a subset. The plan shows this as a filter disappearing rather than as a deletion scope widening, so read any plan that removes a prefix from an expiration rule carefully.

Authoritative scope — who owns what on this resource, declared in internal/scopedecl and machine-checked against the schema.

Enacted and reconciled — every configurable attribute not listed below: the platform applies it, and a refresh reads the truth back.

Create-immutable — bucket: the configuration document belongs to its bucket — the bucket IS the resource's identity.

Example Usage ​

terraform
# Expire objects on a schedule.
#
# There is no storage-class transition rule and no per-object-tag filter: objects
# are not moved between storage classes on a schedule, and the lifecycle API does
# not model tag filters. Both are rejected outright rather than accepted and
# ignored, so scope a rule with prefix.
#
# A bucket carries a SINGLE lifecycle configuration and this resource replaces it
# whole.

resource "frostmoln_bucket_lifecycle_configuration" "example" {
  bucket = frostmoln_bucket.example.name

  rules = [
    {
      id              = "expire-old-logs"
      enabled         = true
      prefix          = "logs/"
      expiration_days = 30
    },
    {
      id                                     = "tidy-up"
      enabled                                = true
      noncurrent_version_expiration_days     = 90
      abort_incomplete_multipart_upload_days = 7
    },
  ]
}

Schema ​

Required ​

  • bucket (String) The name of the bucket whose lifecycle configuration this is. Also the import ID.
  • rules (Attributes List) The lifecycle rules, in order. At least one rule is required — an empty list is refused rather than sent, because the API treats it as "delete the whole lifecycle configuration" and answers 204, which would silently clear the bucket's rules from a config that reads like it is adding them. Use terraform destroy to leave the bucket without a lifecycle configuration. (see below for nested schema)

Nested Schema for rules ​

Required:

  • enabled (Boolean) Whether the rule is applied. A disabled rule is kept but does nothing.

  • id (String) Identifier for the rule. Required, and unique within the bucket.

    Optional:

  • abort_incomplete_multipart_upload_days (Number) Abort a multipart upload that has not completed this many days after it was started, releasing the parts already stored.

  • expiration_days (Number) Delete an object this many days after it was created.

  • noncurrent_version_expiration_days (Number) Delete a noncurrent object version this many days after it stopped being current. Only meaningful on a bucket with versioning enabled.

  • prefix (String) Limits the rule to objects whose key starts with this prefix. OMIT IT to apply the rule to every object in the bucket — an empty string is refused, because it is not transmitted (the field is dropped when empty) and would read back as unset while silently meaning the whole bucket.

Import ​

Import is supported using the following syntax:

The terraform import command can be used, for example:

shell
# Import a bucket's lifecycle configuration by the bucket name.
terraform import frostmoln_bucket_lifecycle_configuration.example "my-data-bucket"