Complete the code to create a Cloud Storage bucket with versioning enabled.
resource "google_storage_bucket" "my_bucket" { name = "my-versioned-bucket" location = "US" versioning { enabled = [1] } }
Setting enabled = true turns on versioning for the bucket, which helps with operational excellence by preserving object versions.
Complete the code to define an alert policy that triggers when CPU usage exceeds 80%.
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" } } }
The alert should trigger when CPU usage is greater than 80%, so the comparison must be COMPARISON_GREATER_THAN.
Fix the error in the Terraform code to enable Stackdriver logging for a Google Cloud Function.
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 }
Google Cloud Functions enable logging by default; to add labels or metadata, use the labels block. There is no direct enable_logging attribute.
Fill both blanks to create a Cloud Logging sink that exports logs to a Pub/Sub topic.
resource "google_logging_project_sink" "pubsub_sink" { name = "pubsub-sink" destination = "pubsub.googleapis.com/projects/my-project/topics/[1]" filter = "severity >= [2]" }
The destination must be the Pub/Sub topic name, here my-topic. The filter uses severity levels like ERROR to capture important logs.
Fill all three blanks to define a Cloud Build trigger that starts on a push to the main branch.
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]"] }] } }
The trigger listens to pushes on the main branch. The build step runs gcloud deploy app.yaml to deploy the app.