oracle.oci.oci_object_storage_object_lifecycle_policy – Manage an ObjectLifecyclePolicy resource in Oracle Cloud Infrastructure

Note

This plugin is part of the oracle.oci collection (version 4.13.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install oracle.oci.

To use it in a playbook, specify: oracle.oci.oci_object_storage_object_lifecycle_policy.

New in version 2.9.0: of oracle.oci

Synopsis

  • This module allows the user to update and delete an ObjectLifecyclePolicy resource in Oracle Cloud Infrastructure

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter Choices/Defaults Comments
api_user
string
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_ID environment variable, if any, is used. This option is required if the user is not specified through a configuration file (See config_file_location). To get the user's OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_fingerprint
string
Fingerprint for the key pair being used. If not set, then the value of the OCI_USER_FINGERPRINT environment variable, if any, is used. This option is required if the key fingerprint is not specified through a configuration file (See config_file_location). To get the key pair's fingerprint value please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_key_file
string
Full path and filename of the private key (in PEM format). If not set, then the value of the OCI_USER_KEY_FILE variable, if any, is used. This option is required if the private key is not specified through a configuration file (See config_file_location). If the key is encrypted with a pass-phrase, the api_user_key_pass_phrase option must also be provided.
api_user_key_pass_phrase
string
Passphrase used by the key referenced in api_user_key_file, if it is encrypted. If not set, then the value of the OCI_USER_KEY_PASS_PHRASE variable, if any, is used. This option is required if the key passphrase is not specified through a configuration file (See config_file_location).
auth_purpose
string
    Choices:
  • service_principal
The auth purpose which can be used in conjunction with 'auth_type=instance_principal'. The default auth_purpose for instance_principal is None.
auth_type
string
    Choices:
  • api_key ←
  • instance_principal
  • instance_obo_user
  • resource_principal
The type of authentication to use for making API requests. By default auth_type="api_key" based authentication is performed and the API key (see api_user_key_file) in your config file will be used. If this 'auth_type' module option is not specified, the value of the OCI_ANSIBLE_AUTH_TYPE, if any, is used. Use auth_type="instance_principal" to use instance principal based authentication when running ansible playbooks within an OCI compute instance.
bucket_name
string / required
The name of the bucket. Avoid entering confidential information. Example: `my-new-bucket1`
cert_bundle
string
The full path to a CA certificate bundle to be used for SSL verification. This will override the default CA certificate bundle. If not set, then the value of the OCI_ANSIBLE_CERT_BUNDLE variable, if any, is used.
config_file_location
string
Path to configuration file. If not set then the value of the OCI_CONFIG_FILE environment variable, if any, is used. Otherwise, defaults to ~/.oci/config.
config_profile_name
string
The profile to load from the config file referenced by config_file_location. If not set, then the value of the OCI_CONFIG_PROFILE environment variable, if any, is used. Otherwise, defaults to the "DEFAULT" profile in config_file_location.
items
list / elements=dictionary
The bucket's set of lifecycle policy rules.
This parameter is updatable.
action
string / required
The action of the object lifecycle policy rule. Rules using the action 'ARCHIVE' move objects from Standard and InfrequentAccess storage tiers into the Archive storage tier. Rules using the action 'INFREQUENT_ACCESS' move objects from Standard storage tier into the Infrequent Access Storage tier. Objects that are already in InfrequentAccess tier or in Archive tier are left untouched. Rules using the action 'DELETE' permanently delete objects from buckets. Rules using 'ABORT' abort the uncommitted multipart-uploads and permanently delete their parts from buckets.
This parameter is updatable.
is_enabled
boolean / required
    Choices:
  • no
  • yes
A Boolean that determines whether this rule is currently enabled.
This parameter is updatable.
name
string / required
The name of the lifecycle rule to be applied.
This parameter is updatable.
object_name_filter
dictionary
exclusion_patterns
list / elements=string
An array of glob patterns to match the object names to exclude. An empty array is ignored. Exclusion patterns take precedence over inclusion patterns. A Glob pattern is a sequence of characters to match text. Any character that appears in the pattern, other than the special pattern characters described below, matches itself. Glob patterns must be between 1 and 1024 characters.
The special pattern characters have the following meanings:
\ Escapes the following character * Matches any string of characters. ? Matches any single character . [...] Matches a group of characters. A group of characters can be: A set of characters, for example: [Zafg9@]. This matches any character in the brackets. A range of characters, for example: [a-z]. This matches any character in the range. [a-f] is equivalent to [abcdef]. For character ranges only the CHARACTER-CHARACTER pattern is supported. [ab-yz] is not valid [a-mn-z] is not valid Character ranges can not start with ^ or : To include a '-' in the range, make it the first or last character.
This parameter is updatable.
inclusion_patterns
list / elements=string
An array of glob patterns to match the object names to include. An empty array includes all objects in the bucket. Exclusion patterns take precedence over inclusion patterns. A Glob pattern is a sequence of characters to match text. Any character that appears in the pattern, other than the special pattern characters described below, matches itself. Glob patterns must be between 1 and 1024 characters.
The special pattern characters have the following meanings:
\ Escapes the following character * Matches any string of characters. ? Matches any single character . [...] Matches a group of characters. A group of characters can be: A set of characters, for example: [Zafg9@]. This matches any character in the brackets. A range of characters, for example: [a-z]. This matches any character in the range. [a-f] is equivalent to [abcdef]. For character ranges only the CHARACTER-CHARACTER pattern is supported. [ab-yz] is not valid [a-mn-z] is not valid Character ranges can not start with ^ or : To include a '-' in the range, make it the first or last character.
This parameter is updatable.
inclusion_prefixes
list / elements=string
An array of object name prefixes that the rule will apply to. An empty array means to include all objects.
This parameter is updatable.
target
string
The target of the object lifecycle policy rule. The values of target can be either "objects", "multipart-uploads" or "previous-object-versions". This field when declared as "objects" is used to specify ARCHIVE, INFREQUENT_ACCESS or DELETE rule for objects. This field when declared as "previous-object-versions" is used to specify ARCHIVE, INFREQUENT_ACCESS or DELETE rule for previous versions of existing objects. This field when declared as "multipart-uploads" is used to specify the ABORT (only) rule for uncommitted multipart-uploads.
This parameter is updatable.
time_amount
integer / required
Specifies the age of objects to apply the rule to. The timeAmount is interpreted in units defined by the timeUnit parameter, and is calculated in relation to each object's Last-Modified time.
This parameter is updatable.
time_unit
string / required
    Choices:
  • DAYS
  • YEARS
The unit that should be used to interpret timeAmount. Days are defined as starting and ending at midnight UTC. Years are defined as 365.2425 days long and likewise round up to the next midnight UTC.
This parameter is updatable.
namespace_name
string / required
The Object Storage namespace used for the request.
region
string
The Oracle Cloud Infrastructure region to use for all OCI API requests. If not set, then the value of the OCI_REGION variable, if any, is used. This option is required if the region is not specified through a configuration file (See config_file_location). Please refer to https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm for more information on OCI regions.
state
string
    Choices:
  • present ←
  • absent
The state of the ObjectLifecyclePolicy.
Use state=present to update an existing an ObjectLifecyclePolicy.
Use state=absent to delete an ObjectLifecyclePolicy.
tenancy
string
OCID of your tenancy. If not set, then the value of the OCI_TENANCY variable, if any, is used. This option is required if the tenancy OCID is not specified through a configuration file (See config_file_location). To get the tenancy OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm

Examples

- name: Update object_lifecycle_policy
  oci_object_storage_object_lifecycle_policy:
    # required
    namespace_name: namespace_name_example
    bucket_name: bucket_name_example

    # optional
    items:
    - # required
      name: name_example
      action: action_example
      time_amount: 56
      time_unit: DAYS
      is_enabled: true

      # optional
      target: target_example
      object_name_filter:
        # optional
        inclusion_prefixes: [ "inclusion_prefixes_example" ]
        inclusion_patterns: [ "inclusion_patterns_example" ]
        exclusion_patterns: [ "exclusion_patterns_example" ]

- name: Delete object_lifecycle_policy
  oci_object_storage_object_lifecycle_policy:
    # required
    namespace_name: namespace_name_example
    bucket_name: bucket_name_example
    state: absent

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
object_lifecycle_policy
complex
on success
Details of the ObjectLifecyclePolicy resource acted upon by the current operation

Sample:
{'items': [{'action': 'action_example', 'is_enabled': True, 'name': 'name_example', 'object_name_filter': {'exclusion_patterns': [], 'inclusion_patterns': [], 'inclusion_prefixes': []}, 'target': 'target_example', 'time_amount': 56, 'time_unit': 'DAYS'}], 'time_created': '2013-10-20T19:20:30+01:00'}
 
items
complex
on success
The live lifecycle policy on the bucket.
For an example of this value, see the PutObjectLifecyclePolicy API documentation.

   
action
string
on success
The action of the object lifecycle policy rule. Rules using the action 'ARCHIVE' move objects from Standard and InfrequentAccess storage tiers into the Archive storage tier. Rules using the action 'INFREQUENT_ACCESS' move objects from Standard storage tier into the Infrequent Access Storage tier. Objects that are already in InfrequentAccess tier or in Archive tier are left untouched. Rules using the action 'DELETE' permanently delete objects from buckets. Rules using 'ABORT' abort the uncommitted multipart-uploads and permanently delete their parts from buckets.

Sample:
action_example
   
is_enabled
boolean
on success
A Boolean that determines whether this rule is currently enabled.

Sample:
True
   
name
string
on success
The name of the lifecycle rule to be applied.

Sample:
name_example
   
object_name_filter
complex
on success

     
exclusion_patterns
list / elements=string
on success
An array of glob patterns to match the object names to exclude. An empty array is ignored. Exclusion patterns take precedence over inclusion patterns. A Glob pattern is a sequence of characters to match text. Any character that appears in the pattern, other than the special pattern characters described below, matches itself. Glob patterns must be between 1 and 1024 characters.
The special pattern characters have the following meanings:
\ Escapes the following character * Matches any string of characters. ? Matches any single character . [...] Matches a group of characters. A group of characters can be: A set of characters, for example: [Zafg9@]. This matches any character in the brackets. A range of characters, for example: [a-z]. This matches any character in the range. [a-f] is equivalent to [abcdef]. For character ranges only the CHARACTER-CHARACTER pattern is supported. [ab-yz] is not valid [a-mn-z] is not valid Character ranges can not start with ^ or : To include a '-' in the range, make it the first or last character.

     
inclusion_patterns
list / elements=string
on success
An array of glob patterns to match the object names to include. An empty array includes all objects in the bucket. Exclusion patterns take precedence over inclusion patterns. A Glob pattern is a sequence of characters to match text. Any character that appears in the pattern, other than the special pattern characters described below, matches itself. Glob patterns must be between 1 and 1024 characters.
The special pattern characters have the following meanings:
\ Escapes the following character * Matches any string of characters. ? Matches any single character . [...] Matches a group of characters. A group of characters can be: A set of characters, for example: [Zafg9@]. This matches any character in the brackets. A range of characters, for example: [a-z]. This matches any character in the range. [a-f] is equivalent to [abcdef]. For character ranges only the CHARACTER-CHARACTER pattern is supported. [ab-yz] is not valid [a-mn-z] is not valid Character ranges can not start with ^ or : To include a '-' in the range, make it the first or last character.

     
inclusion_prefixes
list / elements=string
on success
An array of object name prefixes that the rule will apply to. An empty array means to include all objects.

   
target
string
on success
The target of the object lifecycle policy rule. The values of target can be either "objects", "multipart-uploads" or "previous-object-versions". This field when declared as "objects" is used to specify ARCHIVE, INFREQUENT_ACCESS or DELETE rule for objects. This field when declared as "previous-object-versions" is used to specify ARCHIVE, INFREQUENT_ACCESS or DELETE rule for previous versions of existing objects. This field when declared as "multipart-uploads" is used to specify the ABORT (only) rule for uncommitted multipart-uploads.

Sample:
target_example
   
time_amount
integer
on success
Specifies the age of objects to apply the rule to. The timeAmount is interpreted in units defined by the timeUnit parameter, and is calculated in relation to each object's Last-Modified time.

Sample:
56
   
time_unit
string
on success
The unit that should be used to interpret timeAmount. Days are defined as starting and ending at midnight UTC. Years are defined as 365.2425 days long and likewise round up to the next midnight UTC.

Sample:
DAYS
 
time_created
string
on success
The date and time the object lifecycle policy was created, as described in RFC 3339.

Sample:
2013-10-20T19:20:30+01:00


Authors

  • Oracle (@oracle)