I have setup a GCP project for build activities that support multiple GCP projects deployments, this way I have one place to manage the CI/CD and in this project no other resources APIs like spanner API are enabled.
In the CI/CD GCP projecting I'm using the cloud build and trying to configure the liquibase for spanner schema management and this is failing with error as:
ERROR: Exception Primary Reason: PERMISSION_DENIED: Cloud Spanner API has not been used in project <CLOUD_BUILD_PROJECT_ID> before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/spanner.googleapis.com/overview?project=<CLOUD_BUILD_PROJECT_ID> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry. li
This is the cloud build yaml file looks like:
- id: 'download_liquibase_spanner_extension'
name: 'gcr.io/cloud-builders/wget'
args:
- '-P'
- '/workspace/louhi_ws/drivers'
- 'https://github.com/cloudspannerecosystem/liquibase-spanner/releases/download/4.32.0/liquibase-spanner-4.32.0-all.jar'
- id: 'run_liquibase_update'
name: 'liquibase/liquibase:4.33.0'
env:
- '_TARGET_PROJECT=${_TARGET_PROJECT}'
- '_SPANNER_INSTANCE=${_SPANNER_INSTANCE}'
- '_SPANNER_DATABASE=${_SPANNER_DATABASE}'
args:
- '--changelog-file=/workspace/louhi_ws/changelog/changelog.yaml'
- '--url=jdbc:cloudspanner:/projects/${_TARGET_PROJECT}/instances/${_SPANNER_INSTANCE}/databases/${_SPANNER_DATABASE}'
- '--driver=com.google.cloud.spanner.jdbc.JdbcDriver'
- '--classpath=/workspace/louhi_ws/drivers/liquibase-spanner-4.32.0-all.jar'
- 'update'
waitFor: ['download_liquibase_spanner_extension']
So the questions:
- Is there anyway to pass the target GCP project as input to the liquibase docker, so the target spanner API is used and billed instead of the CI/CD project billing?
- Is there any alternative to manage this flow, where CI/CD is in different project and deployments are in different projects without additional billing on the CI/CD project?