設定值區的生命週期設定

這個範例會為美國多地區中由 Terraform 管理的 Bucket 設定生命週期設定。

深入探索

如需包含這個程式碼範例的詳細說明文件,請參閱下列內容:

程式碼範例

Terraform

如要瞭解如何套用或移除 Terraform 設定,請參閱「基本 Terraform 指令」。 詳情請參閱 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"
    }
  }
}

後續步驟

如要搜尋及篩選其他 Google Cloud 產品的程式碼範例,請參閱Google Cloud 範例瀏覽器