Reputation: 194
I'm trying to set GCS bucket lifecycle policies via Terraform.
As far as I can tell, the google_storage_bucket
resource only allows me to CREATE buckets; and not update existing ones. Trying to run a google_storage_bucket
on an existing bucket raises a 409.
The other storage-related resources do not seem to affect lifecycle policies.
So is it possible to adjust policies on existing buckets via Terraform, or should I switch to gsutil or something else?
Upvotes: 1
Views: 1894
Reputation: 326
You have to import
your bucket to the terraform state before you can change the lifecycle.
my-bucket.tf
terraform import google_storage_bucket.my-bucket my-project/my-bucket
terraform apply -target=google_storage_bucket.my-bucket
Upvotes: 4
Reputation: 941
It seems that Terraform does not have a Google Storage resource to update GCS bucket lifecycle
You can update it via the UI, gsutil or REST API.
Upvotes: 2
Reputation: 153
In Terraform once a bucket has been created, its location can't be changed, use the GCP Console to edit, I add the documentation for buckets.
https://cloud.google.com/storage/docs/access-control/using-iam-permissions
Upvotes: -1