Skip to content

Conversation

@pcboy
Copy link
Contributor

@pcboy pcboy commented Aug 5, 2020

Description

Supports firebase-functions SDK feature in firebase/firebase-functions#752

functions
      .runWith({
        vpcConnector: 'test-connector',
        vpcConnectorEgressSettings: 'PRIVATE_RANGES_ONLY'
      })
      .auth.user()
      .onCreate((user) => user);

It's an important feature for people who want to do a lot more with their firebase cloud functions. For instance connecting their cloud functions to a cloudSQL database.
Check issue #552 in firebase-functions to see that I'm not the only one in need for that feature. Sadly that ticket got closed.

Scenarios Tested

I tested creating a new cloud function with the vpcConnector and the vpcConnectorEgressSettings, it works. I also tried updating a function and works fine too. I also tested without mentioning the vpcConnectorEgressSettings setting and it worked too (will be set as ALL_TRAFFIC by default.)

Sample Commands

No actual change in CLI options. Simply configure the vpcConnector inside your firebase.json file.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@pcboy pcboy force-pushed the add-vpc-connector-to-firebasejson branch from 1eddf9c to 96b2a7d Compare August 5, 2020 11:01
@pcboy
Copy link
Contributor Author

pcboy commented Aug 5, 2020

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Manual indication that this has passed CLA. and removed cla: no labels Aug 5, 2020
@mbleigh
Copy link
Contributor

mbleigh commented Aug 5, 2020

@pcboy thanks for the PR! I do think this is a worthwhile feature to investigate adding, but I don't think adding it to firebase.json config is where I'd want to expose it. I think it's more appropriate for the runWith() options in the firebase-functions SDK.

All SDK/API changes for Firebase have to go through an internal review process before they can be added, and I'm willing to represent this feature internally. I can't promise that we'll be able to dedicate much engineering time to it soon, so if you're amenable to creating a corresponding PR in the firebase-functions repo to add this to runWith and then update this PR to use that instead of firebase.json config, I think we can work toward getting this done.

Cheers!

@pcboy
Copy link
Contributor Author

pcboy commented Aug 6, 2020

@mbleigh Agreed. It seems better to put it in runWith().
I added the PR on the firebase-functions repository.

firebase/firebase-functions#752

@pcboy pcboy force-pushed the add-vpc-connector-to-firebasejson branch 2 times, most recently from 4d0b45c to acded04 Compare August 8, 2020 00:38
@pcboy pcboy force-pushed the add-vpc-connector-to-firebasejson branch 3 times, most recently from 2b3e541 to db2ebf9 Compare August 18, 2020 01:25
Copy link
Contributor

@mbleigh mbleigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good news! The Firebase API review process is done and the API is approved. I have one more change to make it compatible with the decided API, if you can implement we can try to get this shipped!

@pcboy pcboy force-pushed the add-vpc-connector-to-firebasejson branch from db2ebf9 to ea7bdf0 Compare August 18, 2020 22:46
Copy link
Contributor

@mbleigh mbleigh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working with me on this! We'll try to get it launched soon!

Copy link
Contributor

@laurenzlong laurenzlong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this out in conjunction with firebase/firebase-functions#752 and it worked great! Thanks!

Screen Shot 2020-08-20 at 4 15 05 PM

@laurenzlong laurenzlong changed the title Add support for vpcConnector and vpcConnectorEgressSettings in firebase.json Add support for vpcConnector and vpcConnectorEgressSettings customization for functions Aug 20, 2020
@laurenzlong
Copy link
Contributor

Thanks so much for this contribution! We'll try to get it out tomorrow. Also I edited the description to no longer mention firebase.json so it's not confusing. (I got confused at first when reviewing)

@laurenzlong laurenzlong merged commit a6d3419 into firebase:master Aug 20, 2020
@jthegedus
Copy link
Contributor

This is a great addition and will help adoption of Firebase within enterprise orgs! Thanks all!

@leandroIA
Copy link

Hello..
I've been following here, I'm in doubt if this is the right channel to ask.
I saw that they made the updates, but I installed in my code, but when I do the deployment and as if nothing was happening.
It continues to create the functions without the VPC set.

@mbleigh
Copy link
Contributor

mbleigh commented Aug 24, 2020

You will need to make sure you are on version v3.11.0 or later of firebase-functions and version v8.9.0 or later of firebase-tools. That's the most likely reason you're not seeing anything happen.

@leandroIA
Copy link

leandroIA commented Aug 25, 2020 via email

@stijnlw
Copy link

stijnlw commented Dec 14, 2020

@mbleigh I have the same problem as @leandroIA - the extra code (runWith) doesn't seem to do anything at all. The connector is not being attached to the function.

exports.testMysql = functions.runWith({
    vpcConnector: 'vpc-conn-euw1',
    vpcConnectorEgressSettings: 'PRIVATE_RANGES_ONLY'
}).region('europe-west1')
    .https.onCall(async (data, context) => {
        return {'status':'blablabla'};
    })

result:

afbeelding

and this is with a brand new 'firebase-tools' install, like so:

# Install dependencies
apt-get update
apt-get -y install apt-transport-https ca-certificates gnupg curl sudo gcc g++ make rsync git

#Add nodejs for firebase deploy
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt-get update && apt-get install -y nodejs

# Install firebase tools
npm install -g firebase-tools

# Deploy
cd $CI_PROJECT_DIR/firebase/app
firebase use $PROJECT_ID --token $FIREBASE_TOKEN
firebase deploy --only functions -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --token $FIREBASE_TOKEN

firebase -V reports 8.19.0

I don't know how to check version of firebase-functions

@mbleigh
Copy link
Contributor

mbleigh commented Dec 14, 2020

To check firebase-functions version look in the package-lock.json in your functions folder.

@stijnlw
Copy link

stijnlw commented Dec 15, 2020

Thanks a lot for the quick reply, I was on 3.7.0 - now that I'm on 3.13.0 it works as expected. Too bad the firebase deploy doesn't throw an error when you're trying to do things it doesn't support, but it certainly was an easy 'fix'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Manual indication that this has passed CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants