Skip to content

Commit 96b2a7d

Browse files
committed
Add support for vpcConnector and vpcConnectorEgressSettings in firebase.json
1 parent 57d008a commit 96b2a7d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/deploy/functions/release.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ module.exports = function(context, options, payload) {
125125
return Promise.resolve();
126126
}
127127

128+
var vpcConnector = options.config.get("functions.vpcConnector");
129+
var vpcConnectorEgressSettings = options.config.get("functions.vpcConnectorEgressSettings");
130+
128131
var projectId = context.projectId;
129132
var sourceUrl = context.uploadUrl;
130133
var appEngineLocation = getAppEngineLocation(context.firebaseConfig);
@@ -217,6 +220,8 @@ module.exports = function(context, options, payload) {
217220
timeout: functionInfo.timeout,
218221
maxInstances: functionInfo.maxInstances,
219222
environmentVariables: defaultEnvVariables,
223+
vpcConnector: vpcConnector,
224+
vpcConnectorEgressSettings: vpcConnectorEgressSettings,
220225
})
221226
.then((createRes) => {
222227
if (_.has(functionTrigger, "httpsTrigger")) {
@@ -297,6 +302,8 @@ module.exports = function(context, options, payload) {
297302
existingFunction.environmentVariables,
298303
defaultEnvVariables
299304
),
305+
vpcConnector: vpcConnector,
306+
vpcConnectorEgressSettings: vpcConnectorEgressSettings,
300307
};
301308
utils.logBullet(
302309
clc.bold.cyan("functions: ") +

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)