Serverless framework set custom region on Google Cloud

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

service: my-service

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

  - 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)
    - node_modules/**
    - .gitignore
    - .git/**

    handler: http
      - 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.

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

@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.

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

1 Like