PARALLAX

s3_lifecycle

Manage S3 bucket lifecycle rules in AWS

Collection: community.aws

Full Name: community.aws.s3_lifecycle

Synopsis

Manage S3 bucket lifecycle rules in AWS

Parameters

NameTypeRequiredDefaultDescription
abort_incomplete_multipart_upload_daysint
access_keystr
aws_ca_bundlepath
aws_configdict
debug_botocore_endpoint_logsboolfalse
endpoint_urlstr
expiration_datestr
expiration_daysint
expire_object_delete_markerbool
maximum_object_sizeint
minimum_object_sizeint
namestryes
noncurrent_version_expiration_daysint
noncurrent_version_keep_newerint
noncurrent_version_storage_classstrglacier
noncurrent_version_transition_daysint
noncurrent_version_transitionslist
prefixstr
profilestr
purge_transitionsbooltrue
regionstr
rule_idstr
secret_keystr
session_tokenstr
statestrpresent
statusstrenabled
storage_classstrglacier
transition_datestr
transition_daysint
transitionslist
validate_certsbooltrue
waitboolfalse

Example

yaml
- name: Configure a lifecycle rule on a bucket to expire (delete) items with a prefix of /logs/ after 30 days
  community.aws.s3_lifecycle:
    name: mybucket
    expiration_days: 30
    prefix: logs/
    status: enabled
    state: present

- name: Configure a lifecycle rule to transition all items with a prefix of /logs/ to glacier after 7 days and then delete after 90 days
  community.aws.s3_lifecycle:
    name: mybucket
    transition_days: 7
    expiration_days: 90
    prefix: logs/
    status: enabled
    state: present

# Note that midnight GMT must be specified.
# Be sure to quote your date strings
- name: Configure a lifecycle rule to transition all items with a prefix of /logs/ to glacier on 31 Dec 2020 and then delete on 31 Dec 2030.
  community.aws.s3_lifecycle:
    name: mybucket
    transition_date: "2020-12-30T00:00:00.000Z"
    expiration_date: "2030-12-30T00:00:00.000Z"
    prefix: logs/
    status: enabled
    state: present

- name: Disable the rule created above
  community.aws.s3_lifecycle:
    name: mybucket
    prefix: logs/
    status: disabled
    state: present

- name: Delete the lifecycle rule created above
  community.aws.s3_lifecycle:
    name: mybucket
    prefix: logs/
    state: absent

- name: Configure a lifecycle rule to transition all backup files older than 31 days in /backups/ to standard infrequent access class.
  community.aws.s3_lifecycle:
    name: mybucket
    prefix: backups/
    storage_class: standard_ia
    transition_days: 31
    state: present
    status: enabled

- name: Configure a lifecycle rule to transition files to infrequent access after 30 days and glacier after 90
  community.aws.s3_lifecycle:
    name: mybucket
    prefix: logs/
    state: present
    status: enabled
    transitions:
        - transition_days: 30
          storage_class: standard_ia
        - transition_days: 90
          storage_class: glacier
Search
    ↑ ↓ move↵ openesc close