Serverless framework set custom region on Google Cloud

google

#1

I am trying to change the region with serverless.yml like this:

service: my-service

provider:
  name: google
  runtime: nodejs
  project: my-project
  region: europe-west1 <------ CHANGING REGION HERE
  credentials: ~/.gcloud/keyfile.json

plugins:
  - serverless-google-cloudfunctions

# needs more granular excluding in production as only the serverless provider npm
# package should be excluded (and not the whole node_modules directory)
package:
  exclude:
    - node_modules/**
    - .gitignore
    - .git/**

functions:
  first:
    handler: http
    events:
      - http: path

But it does nothing it always falls into the default region us-central1 which is pretty far away. If somebody know how to change this then tell me, thanks.


#2

There are 2 PRs that will allow it, but none of them is merged yet. But you can follow the discussions here:



#3

@KeKs0r Thanks, I found those too but then after 2 hours of digging, I found that deploy command has region flag for specifying a region which seems to work. I was worried that there wasn’t any workaround and I was stuck with US region. Setting default in yml will be nice of course.


#4

I reproduced this issue. +1 for fixing it.

There is a workaround, just put the --region paramter on the cli command:

serverless deploy --region europe-west1

~/jsdev/slsnew > serverless deploy --region europe-west1
Serverless: Compiling with Typescript…
Serverless: Using local tsconfig.json
Serverless: Typescript compiled.
Serverless: Packaging service…
Serverless: Excluding development dependencies…
Serverless: Compiling function “first”…
Serverless: Creating deployment…
Serverless: Checking deployment create progress…

Serverless: Done…
Serverless: Uploading artifacts…
Serverless: Artifacts successfully uploaded…
Serverless: Updating deployment…
Serverless: Checking deployment update progress…

Serverless: Done…
Service Information
service: slsnew
project: mrdm-dev
stage: dev
region: europe-west1

Deployed functions
first
https://europe-west1-mrdm-dev.cloudfunctions.net/hello