Skip to content

Commit abec69b

Browse files
committed
Add support for vpcConnector and vpcConnectorEgressSettings
1 parent 57d008a commit abec69b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/deploy/functions/release.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ module.exports = function(context, options, payload) {
217217
timeout: functionInfo.timeout,
218218
maxInstances: functionInfo.maxInstances,
219219
environmentVariables: defaultEnvVariables,
220+
vpcConnector: functionInfo.vpcConnector,
221+
vpcConnectorEgressSettings: functionInfo.vpcConnectorEgressSettings,
220222
})
221223
.then((createRes) => {
222224
if (_.has(functionTrigger, "httpsTrigger")) {
@@ -292,6 +294,8 @@ module.exports = function(context, options, payload) {
292294
timeout: functionInfo.timeout,
293295
runtime: runtime,
294296
maxInstances: functionInfo.maxInstances,
297+
vpcConnector: functionInfo.vpcConnector,
298+
vpcConnectorEgressSettings: functionInfo.vpcConnectorEgressSettings,
295299
environmentVariables: _.assign(
296300
{},
297301
existingFunction.environmentVariables,

src/gcp/cloudfunctions.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ function _createFunction(options) {
6565
const location = "projects/" + options.projectId + "/locations/" + options.region;
6666
const func = location + "/functions/" + options.functionName;
6767
const endpoint = "/" + API_VERSION + "/" + location + "/functions";
68+
6869
const data = {
6970
sourceUploadUrl: options.sourceUploadUrl,
7071
name: func,
7172
entryPoint: options.entryPoint,
7273
labels: options.labels,
7374
runtime: options.runtime,
7475
};
76+
77+
if (options.vpcConnector) {
78+
data.vpcConnector = options.vpcConnector;
79+
data.vpcConnectorEgressSettings = options.vpcConnectorEgressSettings || "ALL_TRAFFIC";
80+
}
7581
if (options.availableMemoryMb) {
7682
data.availableMemoryMb = options.availableMemoryMb;
7783
}
@@ -143,6 +149,7 @@ function _updateFunction(options) {
143149
const location = "projects/" + options.projectId + "/locations/" + options.region;
144150
const func = location + "/functions/" + options.functionName;
145151
const endpoint = "/" + API_VERSION + "/" + func;
152+
146153
const data = _.assign(
147154
{
148155
sourceUploadUrl: options.sourceUploadUrl,
@@ -153,6 +160,13 @@ function _updateFunction(options) {
153160
);
154161
let masks = ["sourceUploadUrl", "name", "labels"];
155162

163+
if (options.vpcConnector) {
164+
data.vpcConnector = options.vpcConnector;
165+
data.vpcConnectorEgressSettings = options.vpcConnectorEgressSettings || "ALL_TRAFFIC";
166+
masks.push("vpcConnector");
167+
masks.push("vpcConnectorEgressSettings");
168+
}
169+
156170
if (options.runtime) {
157171
data.runtime = options.runtime;
158172
masks = _.concat(masks, "runtime");

0 commit comments

Comments
 (0)