You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::S3::BucketLifecycleConfiguration

Inherits:
Resources::Resource show all
Defined in:
(unknown)

Instance Attribute Summary collapse

Attributes inherited from Resources::Resource

#client, #identifiers

Instance Method Summary collapse

Methods inherited from Resources::Resource

add_data_attribute, add_identifier, #data, data_attributes, #data_loaded?, identifiers, #load, #wait_until

Methods included from Resources::OperationMethods

#add_batch_operation, #add_operation, #batch_operation, #batch_operation_names, #batch_operations, #operation, #operation_names, #operations

Constructor Details

#initialize(bucket_name, options = {}) ⇒ Object #initialize(options = {}) ⇒ Object

Overloads:

  • #initialize(bucket_name, options = {}) ⇒ Object

    Parameters:

    • bucket_name (String)

    Options Hash (options):

    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

  • #initialize(options = {}) ⇒ Object

    Options Hash (options):

    • :bucket_name (required, String)
    • :client (Client)

      When `:client is not given, the options hash is used to construct a new Client object.

Instance Attribute Details

#bucket_nameString (readonly)

Returns:

  • (String)

#rulesArray<Types::LifecycleRule> (readonly)

Container for a lifecycle rule.

Returns:

Instance Method Details

#bucketBucket

Returns:

#delete(options = {}) ⇒ Struct

Deletes the lifecycle configuration from the specified bucket. Amazon S3 removes all the lifecycle configuration rules in the lifecycle subresource associated with the bucket. Your objects never expire, and Amazon S3 no longer automatically deletes any objects on the basis of rules contained in the deleted lifecycle configuration.

To use this operation, you must have permission to perform the s3:PutLifecycleConfiguration action. By default, the bucket owner has this permission and the bucket owner can grant this permission to others.

There is usually some time lag before lifecycle configuration deletion is fully propagated to all the Amazon S3 systems.

For more information about the object expiration, see Elements to Describe Lifecycle Actions.

Related actions include:

Examples:

Request syntax example with placeholder values


bucketlifecycleconfiguration.delete({
  expected_bucket_owner: "AccountId",
  use_accelerate_endpoint: false,
})

Options Hash (options):

  • :expected_bucket_owner (String)

    The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

  • :use_accelerate_endpoint (Boolean)

    When true, the "https://BUCKETNAME.s3-accelerate.amazonaws.com" endpoint will be used.

Returns:

  • (Struct)

    Returns an empty response.

See Also:

#put(options = {}) ⇒ Struct

Creates a new lifecycle configuration for the bucket or replaces an existing lifecycle configuration. For information about lifecycle configuration, see Managing Access Permissions to Your Amazon S3 Resources.

Bucket lifecycle configuration now supports specifying a lifecycle rule using an object key name prefix, one or more object tags, or a combination of both. Accordingly, this section describes the latest API. The previous version of the API supported filtering based only on an object key name prefix, which is supported for backward compatibility. For the related API description, see PutBucketLifecycle.

Rules

You specify the lifecycle configuration in your request body. The lifecycle configuration is specified as XML consisting of one or more rules. Each rule consists of the following:

  • Filter identifying a subset of objects to which the rule applies. The filter can be based on a key name prefix, object tags, or a combination of both.

  • Status whether the rule is in effect.

  • One or more lifecycle transition and expiration actions that you want Amazon S3 to perform on the objects identified by the filter. If the state of your bucket is versioning-enabled or versioning-suspended, you can have many versions of the same object (one current version and zero or more noncurrent versions). Amazon S3 provides predefined actions that you can specify for current and noncurrent object versions.

For more information, see Object Lifecycle Management and Lifecycle Configuration Elements.

Permissions

By default, all Amazon S3 resources are private, including buckets, objects, and related subresources (for example, lifecycle configuration and website configuration). Only the resource owner (that is, the AWS account that created it) can access the resource. The resource owner can optionally grant access permissions to others by writing an access policy. For this operation, a user must get the s3:PutLifecycleConfiguration permission.

You can also explicitly deny permissions. Explicit deny also supersedes any other permissions. If you want to block users or accounts from removing or deleting objects from your bucket, you must deny them permissions for the following actions:

  • s3:DeleteObject

  • s3:DeleteObjectVersion

  • s3:PutLifecycleConfiguration

For more information about permissions, see Managing Access Permissions to Your Amazon S3 Resources.

The following are related to PutBucketLifecycleConfiguration:

Examples:

Request syntax example with placeholder values


bucketlifecycleconfiguration.put({
  lifecycle_configuration: {
    rules: [ # required
      {
        expiration: {
          date: Time.now,
          days: 1,
          expired_object_delete_marker: false,
        },
        id: "ID",
        prefix: "Prefix",
        filter: {
          prefix: "Prefix",
          tag: {
            key: "ObjectKey", # required
            value: "Value", # required
          },
          and: {
            prefix: "Prefix",
            tags: [
              {
                key: "ObjectKey", # required
                value: "Value", # required
              },
            ],
          },
        },
        status: "Enabled", # required, accepts Enabled, Disabled
        transitions: [
          {
            date: Time.now,
            days: 1,
            storage_class: "GLACIER", # accepts GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE
          },
        ],
        noncurrent_version_transitions: [
          {
            noncurrent_days: 1,
            storage_class: "GLACIER", # accepts GLACIER, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, DEEP_ARCHIVE
          },
        ],
        noncurrent_version_expiration: {
          noncurrent_days: 1,
        },
        abort_incomplete_multipart_upload: {
          days_after_initiation: 1,
        },
      },
    ],
  },
  expected_bucket_owner: "AccountId",
  use_accelerate_endpoint: false,
})

Options Hash (options):

  • :lifecycle_configuration (Types::BucketLifecycleConfiguration)

    Container for lifecycle rules. You can add as many as 1,000 rules.

  • :expected_bucket_owner (String)

    The account id of the expected bucket owner. If the bucket is owned by a different account, the request will fail with an HTTP 403 (Access Denied) error.

  • :use_accelerate_endpoint (Boolean)

    When true, the "https://BUCKETNAME.s3-accelerate.amazonaws.com" endpoint will be used.

Returns:

  • (Struct)

    Returns an empty response.

See Also: