googleapis / googleapis/google-cloud-node

Can't connect to VPC

Open
#4,731 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

#### Environment details

- which product (packages/*): @google-cloud/run
- OS: osx
- Node.js version: "1.0.1"
- npm version: "10.1.0"
- google-cloud-node version: "0.0.1-security",

#### Steps to reproduce

Can't connect to vpc connector when using node.js to deploy google cloud run instance. Keep getting this error despite defining the connector properly. Deployment is succesful if I remove the vpcAccess bit.

> Error: 3 INVALID_ARGUMENT: Violation in CreateServiceRequest.service.template.vpc_access.connector: one and only one of connector and network_interfaces must be set.

Stackoverflow seems to think I'm doing it correctly, so I'm wonder if its a side effect of the recent Direct VPC egress release.
```

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();
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.