Soru

Zorluk: OrtaDeploying and Configuring Cloud Storage Buckets and Objects

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?

  1. gcloud storage buckets update gs://financial-reports-repository --lifecycle-file=lifecycle-policy.jsonCevap
  2. B
    gcloud storage buckets create gs://financial-reports-repository --lifecycle-file=lifecycle-policy.json
  3. C
    gsutil lifecycle set lifecycle-policy.json gs://financial-reports-repository
  4. D
    gcloud storage objects update gs://financial-reports-repository --lifecycle-file=lifecycle-policy.json

Cevap

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.

Adım Adım Çözüm

1
Identify the proper Google Cloud CLI surface for Cloud Storage management.
The current standard CLI interface is `gcloud storage` rather than legacy `gsutil` utilities.
Google Cloud recommends `gcloud storage` for performance and integration consistency across GCP management tasks.
2
Select the correct resource target and operation subcommand.
The target is an existing bucket, so the resource group is `buckets` and the action is `update`.
Lifecycle rules are bucket-level configurations and cannot be assigned per object or created on pre-existing buckets with creation flags.
3
Attach the lifecycle rule file using the appropriate flag.
Pass `--lifecycle-file=lifecycle-policy.json` to the update command.
The `--lifecycle-file` flag reads the local JSON rules file and updates the bucket's lifecycle metadata.

Anahtar Kavram

Applying Cloud Storage bucket lifecycle configurations via `gcloud storage`
Bu soruyu puanla