Question

Difficulty: MediumDeploying and Configuring Cloud Storage Buckets and Objects

A cloud engineer needs to apply an automated lifecycle configuration policy file named `lifecycle.json` to an existing Google Cloud Storage bucket named `analytics-raw-data-prod`. According to Google Cloud CLI standards, which command should be executed to apply this lifecycle policy to the bucket?

  1. gcloud storage buckets update gs://analytics-raw-data-prod --lifecycle-file=lifecycle.jsonAnswer
  2. B
    gcloud storage buckets update gs://analytics-raw-data-prod --set-lifecycle=lifecycle.json
  3. C
    gcloud compute buckets update gs://analytics-raw-data-prod --lifecycle-file=lifecycle.json
  4. D
    gcloud storage objects update gs://analytics-raw-data-prod --lifecycle-file=lifecycle.json

Answer

Execute 'gcloud storage buckets update gs://analytics-raw-data-prod --lifecycle-file=lifecycle.json' to apply the lifecycle configuration file to the bucket.
The command 'gcloud storage buckets update gs://analytics-raw-data-prod --lifecycle-file=lifecycle.json' correctly uses the modern gcloud storage CLI interface to update bucket settings with a local JSON lifecycle specification file.

Step-by-Step Solution

1
Identify the resource scope for object lifecycle management
Object lifecycle management rules are defined at the bucket level and apply across objects stored in that bucket.
Lifecycle configuration settings cannot be applied directly to individual objects using object commands.
2
Select the correct gcloud CLI command group
Use the 'gcloud storage buckets update' command group.
Cloud Storage bucket modifications are executed under the 'gcloud storage buckets' sub-command space.
3
Specify the lifecycle configuration parameter
Pass '--lifecycle-file=lifecycle.json' along with the target bucket URI 'gs://analytics-raw-data-prod'.
The '--lifecycle-file' flag is the standard gcloud CLI flag for loading bucket lifecycle rules from a JSON or YAML file.

Key Concept

Configuring Cloud Storage Bucket Lifecycle Rules via gcloud CLI
Rate this question