A DevOps team needs to optimize storage costs for an application logs bucket named `app-logs-prod` by automatically transitioning objects older than 30 days to Nearline Storage and deleting objects older than 365 days. The configuration must be applied using Google Cloud's current recommended CLI tooling. Which command should the team run to apply the local lifecycle configuration file named `lifecycle.json` to the bucket?
- gcloud storage buckets update gs://app-logs-prod --lifecycle-file=lifecycle.jsonAnswer
- Bgsutil lifecycle set lifecycle.json gs://app-logs-prod
- Cgcloud compute buckets update gs://app-logs-prod --lifecycle-file=lifecycle.json
- Dgcloud storage objects update gs://app-logs-prod --lifecycle-file=lifecycle.json
Answer
The command `gcloud storage buckets update gs://app-logs-prod --lifecycle-file=lifecycle.json` correctly updates the Cloud Storage bucket with the lifecycle rules.
The command starting with `gcloud storage buckets update` correctly specifies the bucket resource group and uses the `--lifecycle-file` flag to attach a JSON lifecycle configuration to an existing Cloud Storage bucket following current GCP CLI best practices.
Step-by-Step Solution
Key Concept
Deploying Cloud Storage Bucket Lifecycle Configurations with gcloud CLI