GoogleCloudPlatform / k8s-config-connector

GCP Config Connector, a Kubernetes add-on for managing GCP resources
https://cloud.google.com/config-connector/docs/overview
Apache License 2.0
882 stars 215 forks source link

Failure to set billing ID on newly-created project #187

Closed andudo closed 4 years ago

andudo commented 4 years ago

Describe the bug I tried creating a project in a folder using the configuration from here https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/blob/master/config-connector/solutions/projects/kpt/project-hierarchy/project.yaml

This could also be done using the example from official docs https://cloud.google.com/config-connector/docs/reference/resources#project_in_folder

The project gets created, but it fails to set billing on it because billing API is not enabled on this project.

error: "Update call failed: error applying desired state: Error setting billing account "XXXXXX-XXXXXX-XXXXXX" for project "projects/project-hierarchy-project": googleapi: Error 403: Cloud Billing API has not been used in project XXXXXXXXX before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudbilling.googleapis.com/overview?project=XXXXXXXXX then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured"

Could APIs be enabled on projects via its YAML configuration?

ConfigConnector Version 1.9.1

To Reproduce Try to create a new project with billing account.

YAML snippets:

apiVersion: resourcemanager.cnrm.cloud.google.com/v1beta1
kind: Project
metadata:
  annotations:
    cnrm.cloud.google.com/folder-id: "${FOLDER_NUMBER}"
  name: project-hierarchy-project
spec:
  name: project-hierarchy-project
  billingAccountRef:
    external: "${BILLING_ACCOUNT_ID}"
andudo commented 4 years ago

Sorry that was actually my own fault (the API was not enabled on the host project, not on the new one). No issue there.