I'm setting up a deployment manager package in .jinja which does the following: - Creates VPC Network, Subnet and Private Range for GCP Services - Creates the peering between 'servicenetworking.googleapis.com' and my VPC network - Assigns the Cloud SQL database into the private range assigned to google services within my VPC
The second step is proving impossible with deployment manager as there is no action that can be called to do this. I have confirmed the fix manually at this stage is to call the following gcloud command and then set up the Cloud SQL database in the VPC:
gcloud services vpc-peerings connect --service=servicenetworking.googleapis.com --ranges=<my-range> --network=<my-network> --project=<my-project>
Using the following gcp-type in my .jinja isn't sufficient as it doesn't allow mapping to pre-existing gcp services but expects a source and destination network.
- name: {{ env['deployment' ]}}-gcp-private-vpc-peering
action: gcp-types/compute-v1:compute.networks.addPeering
metadata:
runtimePolicy:
- CREATE
properties:
network: $(ref.{{ env['deployment']}}-network.name)
name: {{ env['deployment' ]}}-gcp-private-vpc-peering
autoCreateRoutes: true
peerNetwork: servicenetworking.googleapis.com
dependsOn:
- $(ref.{{ env['deployment']}}-network.selfLink)
Is there a way to call the gcloud command from the deployment manager, or an action I can call upon to achieve the service peering. I can confirm the Service API is indeed enabled on the project.
(Note that the destination VPC and project are variable, assigned by Google therefore I cannot enter this value into the above template)
Update 05/07/19 I believe I have found the API service call I need to do, but I'm very unsure of the syntax to actually make the call to create the service link from deployment manager:
Need a bit of direction - similar to below?
- name: {{ env['deployment' ]}}-gcp-private-vpc-peering
action: gcp-types/servicenetworking.googleapis.com:services.connections
metadata:
runtimePolicy:
- CREATE
properties:
propertyA: valueA
...