Complete the code to enable autoscaling for a Google Cloud Compute Engine instance group.
gcloud compute instance-groups managed set-autoscaling [1] --max-num-replicas=10 --min-num-replicas=1 --target-cpu-utilization=0.6 --zone=my-zone
The command requires the name of the instance group to set autoscaling.
Complete the code to create a Cloud CDN-enabled backend service.
gcloud compute backend-services create [1] --enable-cdn --protocol=HTTP --port-name=http --globalThe backend service name is required to create a CDN-enabled backend service.
Fix the error in the Terraform snippet to enable autoscaling on a GCP instance group.
resource "google_compute_autoscaler" "autoscaler" { name = "autoscaler-example" target = google_compute_instance_group_manager.example.[1] autoscaling_policy { max_replicas = 5 min_replicas = 1 cpu_utilization { target = 0.6 } } }
The autoscaler target must be the self_link of the instance group manager resource.
Fill both blanks to configure a Cloud Storage bucket for website hosting with caching.
resource "google_storage_bucket" "website_bucket" { name = "my-website-bucket" location = "US" website { main_page_suffix = [1] not_found_page = [2] } uniform_bucket_level_access = true }
The main page suffix is usually "index.html" and the not found page is "404.html" for website hosting.
Fill all three blanks to create a Cloud Run service with autoscaling based on concurrency and CPU utilization.
resource "google_cloud_run_service" "service" { name = "my-service" location = "us-central1" template { spec { containers { image = "gcr.io/my-project/my-image" resources { limits = { cpu = [1] } } } container_concurrency = [2] } } traffic { percent = 100 latest_revision = true } autogenerate_revision_name = true metadata { annotations = { "autoscaling.knative.dev/target" = "[3]" } } }
CPU limit is set as a string "1" (1 CPU), container concurrency is an integer 10, and autoscaling target annotation is a string "80" representing 80% CPU utilization.