0
0
GCPcloud~10 mins

Operational excellence in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Cloud Storage bucket with versioning enabled.

GCP
resource "google_storage_bucket" "my_bucket" {
  name     = "my-versioned-bucket"
  location = "US"
  versioning {
    enabled = [1]
  }
}
Drag options to blanks, or click blank then click option'
Aenabled
Bfalse
Con
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings like 'enabled' or 'on' instead of boolean true/false
Setting versioning to false disables version control
2fill in blank
medium

Complete the code to define an alert policy that triggers when CPU usage exceeds 80%.

GCP
resource "google_monitoring_alert_policy" "high_cpu" {
  display_name = "High CPU Usage"
  combiner    = "OR"
  conditions {
    display_name = "CPU Usage Condition"
    condition_threshold {
      filter     = "metric.type=\"compute.googleapis.com/instance/cpu/utilization\""
      comparison = [1]
      threshold_value = 0.8
      duration   = "60s"
    }
  }
}
Drag options to blanks, or click blank then click option'
ACOMPARISON_GREATER_THAN
BCOMPARISON_LESS_THAN
CCOMPARISON_EQUAL
DCOMPARISON_NOT_EQUAL
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'COMPARISON_LESS_THAN' which triggers on low CPU usage
Using 'COMPARISON_EQUAL' which rarely matches exactly
3fill in blank
hard

Fix the error in the Terraform code to enable Stackdriver logging for a Google Cloud Function.

GCP
resource "google_cloudfunctions_function" "func" {
  name        = "my-function"
  runtime     = "python39"
  entry_point = "main"
  source_archive_bucket = "my-source-bucket"
  source_archive_object = "function-source.zip"
  trigger_http = true
  [1] = true
}
Drag options to blanks, or click blank then click option'
Aenable_logging
Blogging_enabled
Clabels
Dlog_enabled
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to set a non-existent boolean attribute to enable logging
Using incorrect attribute names that cause errors
4fill in blank
hard

Fill both blanks to create a Cloud Logging sink that exports logs to a Pub/Sub topic.

GCP
resource "google_logging_project_sink" "pubsub_sink" {
  name        = "pubsub-sink"
  destination = "pubsub.googleapis.com/projects/my-project/topics/[1]"
  filter      = "severity >= [2]"
}
Drag options to blanks, or click blank then click option'
Amy-topic
BERROR
CWARNING
Dlogs-topic
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong topic name or format in destination
Using a severity level that is too low or invalid
5fill in blank
hard

Fill all three blanks to define a Cloud Build trigger that starts on a push to the main branch.

GCP
resource "google_cloudbuild_trigger" "trigger" {
  name = "main-branch-trigger"
  github {
    owner = "my-org"
    name  = "my-repo"
    push {
      branch = "[1]"
    }
  }
  build {
    steps = [{
      name = "gcr.io/cloud-builders/gcloud"
      args = ["[2]", "[3]"]
    }]
  }
}
Drag options to blanks, or click blank then click option'
Amain
Bapp.yaml
Cdeploy
Dmaster
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'master' instead of 'main' for the branch name
Swapping the order of 'deploy' and 'app.yaml' in args