Question

Difficulty: MediumDeploying and Configuring Cloud Storage Buckets and Objects

A DevOps team needs to set up a Google Cloud Storage bucket named `iot-log-repository` in the `europe-west1` region to hold daily application logs. The team has prepared a local configuration file named `lifecycle.json` containing lifecycle rules to transition objects to Nearline storage after 30 days and delete them after 365 days. Which set of commands represents the Google-recommended approach using the modern Google Cloud CLI to provision the bucket and apply this lifecycle policy?

  1. Run `gcloud storage buckets create gs://iot-log-repository --location=europe-west1` followed by `gcloud storage buckets update gs://iot-log-repository --lifecycle-file=lifecycle.json`.Answer
  2. B
    Run `gsutil mb -l europe-west1 gs://iot-log-repository` followed by `gcloud storage buckets update gs://iot-log-repository --lifecycle-file=lifecycle.json`.
  3. C
    Run `gcloud storage buckets create gs://iot-log-repository --location=europe-west1 --default-storage-class=NEARLINE` without applying the lifecycle JSON policy file.
  4. D
    Run `gcloud storage buckets create gs://iot-log-repository --location=europe-west1` followed by `gcloud storage objects update gs://iot-log-repository/* --lifecycle-file=lifecycle.json`.

Answer

Execute `gcloud storage buckets create gs://iot-log-repository --location=europe-west1` to provision the bucket, then execute `gcloud storage buckets update gs://iot-log-repository --lifecycle-file=lifecycle.json` to assign the lifecycle policy.
The standard Google-recommended command for provisioning a Cloud Storage bucket is `gcloud storage buckets create`. Modifying bucket properties, including setting lifecycle management rules from a JSON specification file, is accomplished via `gcloud storage buckets update --lifecycle-file=FILENAME`.

Step-by-Step Solution

1
Provision the Cloud Storage bucket using modern CLI tools.
Bucket `gs://iot-log-repository` is created in `europe-west1` using `gcloud storage buckets create`.
Google Cloud recommends `gcloud storage` over `gsutil` for improved performance and unified CLI experience.
2
Apply the lifecycle rule configuration.
The bucket lifecycle configuration is updated via `gcloud storage buckets update --lifecycle-file=lifecycle.json`.
Lifecycle rules govern object retention and storage class transitions at the bucket resource level.

Key Concept

Cloud Storage Bucket Provisioning and Lifecycle Management with gcloud storage CLI
Rate this question