A DevOps team manages a Cloud Storage bucket named `financial-reports-repository` that receives daily transaction exports. To comply with cost optimization guidelines, all objects in the bucket must automatically transition to Nearline storage after 30 days of creation. A cloud engineer has authored a local JSON lifecycle configuration file named `lifecycle-policy.json`. Which command should the engineer execute to apply this lifecycle policy to the existing bucket?
- gcloud storage buckets update gs://financial-reports-repository --lifecycle-file=lifecycle-policy.jsonAnswer
- Bgcloud storage buckets create gs://financial-reports-repository --lifecycle-file=lifecycle-policy.json
- Cgsutil lifecycle set lifecycle-policy.json gs://financial-reports-repository
- Dgcloud storage objects update gs://financial-reports-repository --lifecycle-file=lifecycle-policy.json
Answer
To configure a lifecycle policy on an existing Google Cloud Storage bucket using current Google Cloud CLI best practices, run `gcloud storage buckets update gs://[BUCKET_NAME] --lifecycle-file=[FILENAME]`.
Applying a lifecycle configuration file to an existing Cloud Storage bucket requires using `gcloud storage buckets update` paired with the `--lifecycle-file` flag. This correctly updates the bucket-level metadata according to Google Cloud CLI standards.
Step-by-Step Solution
Key Concept
Applying Cloud Storage bucket lifecycle configurations via `gcloud storage`