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:

- [Manage object lifecycles](https://docs.cloud.google.com/storage/docs/managing-lifecycles.md.txt)

## Code sample

### Terraform


To learn how to apply or remove a Terraform configuration, see
[Basic Terraform commands](https://docs.cloud.google.com/docs/terraform/basic-commands.md.txt).


For more information, see the
[Terraform provider reference documentation](https://registry.terraform.io/providers/hashicorp/google/latest/docs).

```terraform
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](https://docs.cloud.google.com/docs/samples.md.txt?product=storage).