Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Unable to setup Apigee X via Terraform

I'm trying to setup apigee-x in a existing gcp project but somehow, an error is showing up concerning to a contraint related to resource location which in the particular case is europe-west1

module.apigee.google_apigee_organization.organization[0]: Creating...
╷
│ Error: Error creating Organization: googleapi: Error 400: Precondition check failed.
│ Details:
│ [
│   {
│     "@type": "type.googleapis.com/google.rpc.PreconditionFailure",
│     "violations": [
│       {
│         "description": "'global' violates constraint `constraints/gcp.resourceLocations` on the resource 'projects/*****, field name: Control Plane Region'",
│         "subject": "orgpolicy:projects/*****?zone=global",
│         "type": "constraints/gcp.resourceLocations"
│       }
│     ]
│   }
│ ]
│
│   with module.apigee.google_apigee_organization.organization[0],
│   on .terraform/modules/apigee/modules/apigee/main.tf line 22, in resource "google_apigee_organization" "organization":
│   22: resource "google_apigee_organization" "organization" {

Note: project_id was obfuscated.. 

Bellow the tf definition

module "apigee" {
  source     = "github.com/terraform-google-modules/cloud-foundation-fabric//modules/apigee?ref=v28.0.0"
  project_id = var.project_id
  organization = {
    display_name            = var.project_id
    description             = "default org"
    authorized_network      = var.vpc_network
    runtime_type            = "CLOUD"
    project_id              = var.project_id
    billing_type            = "EVALUATION"
    #database_encryption_key = module.kms-org-db.key_ids["org-db"]
    analytics_region        = "europe-west1"
    api_consumer_data_location = "europe-west1"
  }
  envgroups = {
    dev = ["test.api.example.com"]
  }
  environments = {
    dev = {
      display_name = "dev"
      description  = "sample"
      envgroups    = ["dev"]
    }
  }
  instances = {
    europe-west1 = {
      region                        = "europe-west1"
      environments                  = ["dev"]
      runtime_ip_cidr_range         = "****/22"
      troubleshooting_ip_cidr_range = "****/22"
    }
  }
}

Ideas for troubleshooting? 

Lack of permissions? Collisions in available ip's range? 

Thanks.

Solved Solved
0 10 1,523
1 ACCEPTED SOLUTION

Hi,

the answer for this can be seen here:

https://issuetracker.google.com/issues/325695173?pli=1

The attribute to avoid this constraint is api_consumer_data_location and it's available in the last versions of tf module.

Best,

David.

View solution in original post

10 REPLIES 10