Skip to content

Deploy fails when using org policy constraints/gcp.resourceLocations #1978

@chilversc

Description

@chilversc

Environment info

firebase-tools: 7.12.1
Platform: Ubuntu 18.04

Steps to reproduce

  • Create a GCP project and enable the organisation policy "constraints/gcp.resourceLocations".
  • Ensure that us-central1 is not included in the list of allowed regions.
  • Try to deploy a cloud function using the firebase tool that is set to use a valid region.

Expected behavior

The function should be deployed.

Actual behavior

The function fails to deploy with the following error:

"error": {
  "code": 400,
  "message": "The request has violated one or more Org Policies. Please refer to the respective violations for more information."
  "status": "FAILED_PRECONDITION" 
  "details\": [
    {
      "@type": "type.googleapis.com/google.rpc.PreconditionFailure",
      "violations": [
        {
          "type": "constraints/gcp.resourceLocations",
          "subject": "orgpolicy:projects/<project>",
          "description": "Constraint constraints/gcp.resourceLocations violated for projects/<project> attempting GenerateUploadUrlActionV1 with location set to us-central1. See https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints for more information."
        }
      ]
    }
  ]
}

Source

This issue comes from the following lines which hard code the region as us-central1 when generating the upload URL for the cloud functions.

DEFAULT_REGION: "us-central1",

var GCP_REGION = gcp.cloudfunctions.DEFAULT_REGION;

.generateUploadUrl(context.projectId, GCP_REGION)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions