Trying to deploy a google cloud run with a private VPC connector instance using a node.js script. Keep getting this error when I try to run it:
Error: 3 INVALID_ARGUMENT: Violation in CreateServiceRequest.service.template.vpc_access.connector: one and only one of connector and network_interfaces must be set.
I've spent time looking at google's documentation and can't figure out what I'm doing wrong. Script deploys the image fine when I remove the vpcAccess bit. Judging from the error, I must be defining 'connector' incorrectly. What am I missing here?
const parent = 'projects/***/locations/us-central1';
const service = {
template: {
vpcAccess: [
{
connector: 'projects/***/locations/us-central1/connectors/socket-connector-name',
egress: 'private-ranges-only'
}
],
containers: [
{
image: '***',
},
]
},
};
const serviceId = 'abc123';
const { ServicesClient } = require('@google-cloud/run').v2;
const runClient = new ServicesClient();
async function callCreateService() {
const request = {
parent,
service,
serviceId,
};
const [operation] = await runClient.createService(request);
const [response] = await operation.promise();
console.log(response);
}
callCreateService();