Question

Difficulty: HardDeploying Infrastructure using Deployment Manager or Terraform

A Cloud Engineer is deploying a multi-tier application infrastructure containing Compute Engine instances and a Cloud SQL database into a newly created target project named `prod-data-project` using Google Cloud Deployment Manager. The deployment templates are maintained in a central repository and executed from a centralized CI/CD host project `ops-ci-project`. When executing `gcloud deployment-manager deployments create prod-stack --config=main.yaml --project=prod-data-project`, the deployment fails with an error indicating that the Cloud SQL Admin API (`sqladmin.googleapis.com`) is not enabled. Which action should the engineer take to resolve this issue?

  1. Enable the `sqladmin.googleapis.com` API inside the `prod-data-project` project.Answer
  2. B
    Enable the `sqladmin.googleapis.com` API inside the `ops-ci-project` host project.
  3. C
    Grant the primitive `roles/owner` role to the Google Deployment Manager service account in `ops-ci-project`.
  4. D
    Append the `--auto-enable-apis` flag to the `gcloud deployment-manager deployments create` command.

Answer

Enable the Cloud SQL Admin API (`sqladmin.googleapis.com`) directly in the target project `prod-data-project` where the infrastructure resources are being instantiated.
When deploying infrastructure via Deployment Manager or Terraform across projects, Google Cloud service APIs must be enabled within the target project (`prod-data-project`) where the actual cloud resources (such as Cloud SQL) are created. Enabling the API in the target project grants Deployment Manager permission to manage that specific API's resources.

Step-by-Step Solution

1
Identify the target project where infrastructure resources are being provisioned by Deployment Manager.
The target project is `prod-data-project` as specified by the `--project` flag.
Google Cloud service APIs manage resources within the boundary of the specific project where those resources live.
2
Enable the required service API (`sqladmin.googleapis.com`) in the target project.
The API is activated for `prod-data-project`.
Deployment Manager API calls on behalf of a deployment fail if the required service API is disabled in the resource target project.
3
Re-run the deployment command `gcloud deployment-manager deployments create prod-stack --config=main.yaml --project=prod-data-project`.
The Deployment Manager service provisions the Cloud SQL database and associated resources successfully.
With the target API enabled, Deployment Manager has authorization to instantiate Cloud SQL resources.

Key Concept

API Enablement Scoping for Infrastructure as Code
Rate this question