Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
Overview Configuration samples
This page describes how to set Object Lifecycle Management on a bucket and how to view a bucket's current lifecycle configuration. Lifecycle configurations apply to all current and future objects in the bucket.
Required rolesTo get the permissions that you need to set and manage Object Lifecycle Management for a bucket, ask your administrator to grant you the Storage Admin (roles/storage.admin
) role on the bucket. This predefined role contains the permissions required to set and manage Object Lifecycle Management for a bucket. To see the exact permissions required, expand the Required permissions section:
storage.buckets.get
storage.buckets.list
storage.buckets.update
You might also be able to get these permissions with custom roles.
For information about granting roles on buckets, see Set and manage IAM policies on buckets.
Set the lifecycle configuration for a bucket Warning: When you change your lifecycle configuration, Object Lifecycle Management may still perform actions based on the old configuration for up to 24 hours. For example, if you change anAge
condition from 10 days to 20 days, an object that is 11 days old could be deleted by Object Lifecycle Management up to 24 hours later, based on the old configuration. Console
In the bucket list, find the bucket you want to enable, and click the bucket's name.
Click the Lifecycle tab.
The lifecycle rules page appears. From here you can edit or delete existing rules. To add a new rule:
Click Add a rule.
In the page that appears, specify a configuration.
Select the action to take when an object meets the conditions.
Click Continue.
Select the conditions under which an action is taken.
Click Continue.
Click Create.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Command lineCreate a JSON file with the lifecycle configuration rules you would like to apply. See configuration examples for sample JSON files.
Use the gcloud storage buckets update
command with the --lifecycle-file
flag:
gcloud storage buckets update gs://BUCKET_NAME --lifecycle-file=LIFECYCLE_CONFIG_FILE
Where:
BUCKET_NAME
is the name of the relevant bucket. For example, my-bucket
.LIFECYCLE_CONFIG_FILE
is the path for the JSON file that you created in Step 1.For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample sets a lifecycle configuration on a bucket:
The following sample removes any existing lifecycle configuration from on a bucket:
TerraformYou can use a Terraform resource to set a lifecycle configuration for a bucket managed by Terraform. To set a lifecycle configuration on an existing bucket that isn't yet managed by Terraform, you must first import the existing bucket.
To find out whether a lifecycle condition is supported by Terraform, see the Terraform documentation for the condition
block.
In the bucket list, the lifecycle status of each bucket is found in the Lifecycle column.
You can click this status to add, view, edit, and delete rules.
To learn how to get detailed error information about failed Cloud Storage operations in the Google Cloud console, see Troubleshooting.
Command lineUse the gcloud storage buckets describe
command with the --format
flag:
gcloud storage buckets describe gs://BUCKET_NAME --format="default(lifecycle_config)"
Where BUCKET_NAME
is the name of the bucket whose lifecycle configuration you want to view. For example, my-bucket
.
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
To view the bucket's lifecycle policies, follow the instructions for displaying a bucket's metadata and look for the lifecycle policy fields in the response. REST APIs What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-02 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.5