TerraformでGCSのライフサイクル設定

概要

GCPのGCS(ストレージ)でライフサイクルをTerraformで設定する例です。

バケット内のオブジェクトが365日経過後に自動削除されるよう設定しています。

resource "google_storage_bucket" "image-store" {
  name          = "image-store-bucket"
  location      = "asia-northeast1"

  lifecycle_rule {
    action {
      type = "Delete"
    }

    condition {
      age     = "365"
      is_live = "true"
    }
  }
}