Set the lifecycle configuration for a Bucket

This sample sets a lifecycle configuration for a Bucket managed by Terraform in the US multi-region.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

Terraform

To learn how to apply or remove a Terraform configuration, see Basic Terraform commands . For more information, see the Terraform provider reference documentation .

  resource 
  
 "random_id" 
  
 "bucket_prefix" 
  
 { 
  
 byte_length 
  
 = 
  
 8 
 } 
 resource 
  
 "google_storage_bucket" 
  
 "auto_expire" 
  
 { 
  
 provider 
  
 = 
  
 google-beta 
  
 name 
  
 = 
  
 "${random_id.bucket_prefix.hex}-example-bucket" 
  
 location 
  
 = 
  
 "US" 
  
 lifecycle_rule 
  
 { 
  
 condition 
  
 { 
  
 age 
  
 = 
  
 3 
  
 } 
  
 action 
  
 { 
  
 type 
  
 = 
  
 "Delete" 
  
 } 
  
 } 
 } 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: