hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.28k stars 1.72k forks source link

google cloud composer shows ip_allocation_policy attributes as required. But shows conflicted when the same are provided. #6579

Closed kikuingithub closed 4 years ago

kikuingithub commented 4 years ago

Community Note

Terraform Version - 0.12.20

Affected Resource(s)

Terraform Configuration Files

resource "google_composer_environment" "dwh-composer-XXXr" {
  name    = "${var.env}-dwh-composer-XXXXr"
  project = "${var.service_project}"
  region  = "${var.region}"
  config {
    node_count = 3
    node_config {
      zone            = "${var.zone}"
      disk_size_gb    = 100
      machine_type    = "n1-standard-1"
      network         = "${var.shared_vpc}"
      subnetwork      = "${var.shared_subnet}"
      service_account = "${google_service_account.cloud-composer.name}"

      ip_allocation_policy = [{
        cluster_ipv4_cidr_block       = "192.168.0.0/22"
       cluster_secondary_range_name  = "<secondary_range>"
        services_ipv4_cidr_block      = "192.168.4.0/24"
        services_secondary_range_name = "<secondary_service_name>"
        use_ip_aliases                =  true
        }
      ] 
    }
    software_config {
      python_version = "3"
    }

  }
  depends_on = [google_project_iam_member.composer-worker]
}

Debug Output

Panic Output

Expected Behavior

cloud composer should accept the ip_allocation_policy block attributes and should create the composer environment.

Actual Behavior

Error: "config.0.node_config.0.ip_allocation_policy.0.cluster_secondary_range_name": conflicts with config.0.node_config.0.ip_allocation_policy.0.cluster_ipv4_cidr_block

on main.tf line 45, in resource "google_composer_environment" "dwh-composer-XXXr": 45: resource "google_composer_environment" "dwh-composer-XXXr" {

Error: "config.0.node_config.0.ip_allocation_policy.0.services_secondary_range_name": conflicts with config.0.node_config.0.ip_allocation_policy.0.services_ipv4_cidr_block

on main.tf line 45, in resource "google_composer_environment" "dwh-composer-XXXr": 45: resource "google_composer_environment" "dwh-composer-XXXr" {

Error: "config.0.node_config.0.ip_allocation_policy.0.cluster_ipv4_cidr_block": conflicts with config.0.node_config.0.ip_allocation_policy.0.cluster_secondary_range_name

on main.tf line 45, in resource "google_composer_environment" "dwh-composer-XXX": 45: resource "google_composer_environment" "dwh-composer-XXXr" {

Error: "config.0.node_config.0.ip_allocation_policy.0.services_ipv4_cidr_block": conflicts with config.0.node_config.0.ip_allocation_policy.0.services_secondary_range_name

on main.tf line 45, in resource "google_composer_environment" "dwh-composer-XXXr": 45: resource "google_composer_environment" "dwh-composer-XXXr" {

Steps to Reproduce

  1. terraform apply

Important Factoids

References

edwardmedia commented 4 years ago

@kikuingithub can you post the debug log so I can take a close look?

kikuingithub commented 4 years ago

Hi Edward,

Thanks for the quick turnaround ! Here are the debug logs.

2020-06-12T20:36:52.698+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Authenticating using DefaultClient... 2020-06-12T20:36:52.698+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] -- Scopes: [https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/ndev.clouddns.readwrite https://www.googleapis.com/auth/devstorage.full_control https://www.googleapis.com/auth/userinfo.email] 2020-06-12T20:36:52.699+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating GCE client for path https://www.googleapis.com/compute/v1/projects/ 2020-06-12T20:36:52.699+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating GCE Beta client for path https://www.googleapis.com/compute/beta/projects/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating GKE client for path https://container.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating GKE Beta client for path https://container.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud DNS client for path https://www.googleapis.com/dns/v1/projects/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud DNS Beta client for path https://www.googleapis.com/dns/v1beta2/projects/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud KMS client for path https://cloudkms.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Stackdriver Logging client for path https://logging.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Storage client for path https://www.googleapis.com/storage/v1/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google SqlAdmin client for path https://sqladmin.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Pubsub client for path https://pubsub.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Dataflow client for path https://dataflow.googleapis.com/ 2020-06-12T20:36:52.700+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud ResourceManager client for path https://cloudresourcemanager.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud ResourceManager V client for path https://cloudresourcemanager.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Runtimeconfig client for path https://runtimeconfig.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud IAM client for path https://iam.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud IAMCredentials client for path https://iamcredentials.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Service Management client for path https://servicemanagement.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Service Usage client for path https://serviceusage.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Billing client for path https://cloudbilling.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Build client for path https://cloudbuild.googleapis.com/ 2020-06-12T20:36:52.701+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud BigQuery client for path https://www.googleapis.com/bigquery/v2/ 2020-06-12T20:36:52.703+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud CloudFunctions Client for path https://cloudfunctions.googleapis.com/ 2020/06/12 20:36:52 [TRACE] [walkPlan] Exiting eval tree: provider.google 2020/06/12 20:36:52 [TRACE] vertex "provider.google": visit complete 2020-06-12T20:36:52.703+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud BigtableAdmin for path https://bigtableadmin.googleapis.com/ 2020/06/12 20:36:52 [TRACE] dag/walk: visiting "google_composer_environment.dwh-composer-7te458r" 2020/06/12 20:36:52 [TRACE] vertex "google_composer_environment.dwh-composer-7te458r": starting visit (terraform.NodePlannableResource) 2020/06/12 20:36:52 [TRACE] vertex "google_composer_environment.dwh-composer-7te458r": evaluating 2020-06-12T20:36:52.704+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Source Repo client for path https://sourcerepo.googleapis.com/ 2020/06/12 20:36:52 [TRACE] [walkPlan] Entering eval tree: google_composer_environment.dwh-composer-7te458r 2020-06-12T20:36:52.704+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Spanner client for path https://spanner.googleapis.com/ 2020-06-12T20:36:52.704+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Dataproc client for path https://dataproc.googleapis.com/ 2020/06/12 20:36:52 [TRACE] : eval: terraform.EvalWriteResourceState 2020-06-12T20:36:52.704+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Dataproc Beta client for path https://dataproc.googleapis.com/ 2020-06-12T20:36:52.704+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Filestore client for path https://file.googleapis.com/ 2020-06-12T20:36:52.704+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud IoT Core client for path https://cloudiot.googleapis.com/ 2020-06-12T20:36:52.705+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating App Engine client for path https://appengine.googleapis.com/ 2020-06-12T20:36:52.705+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Cloud Composer client for path https://composer.googleapis.com/ 2020-06-12T20:36:52.705+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Service Networking client for path https://servicenetworking.googleapis.com/ 2020-06-12T20:36:52.705+0530 [DEBUG] plugin.terraform-provider-google_v3.13.0_x5.exe: 2020/06/12 20:36:52 [INFO] Instantiating Google Cloud Storage Transfer client for path https://storagetransfer.googleapis.com/ 2020/06/12 20:36:52 [TRACE] [walkPlan] Exiting eval tree: google_composer_environment.dwh-composer-7te458r 2020/06/12 20:36:52 [TRACE] vertex "google_composer_environment.dwh-composer-7te458r": expanding dynamic subgraph 2020/06/12 20:36:52 [TRACE] Executing graph transform terraform.ResourceCountTransformer 2020/06/12 20:36:52 [TRACE] Completed graph transform terraform.ResourceCountTransformer with new graph: google_composer_environment.dwh-composer-7te458r - *terraform.NodePlannableResourceInstance

2020/06/12 20:36:52 [TRACE] Executing graph transform terraform.OrphanResourceCountTransformer 2020/06/12 20:36:52 [TRACE] Completed graph transform terraform.OrphanResourceCountTransformer (no changes) 2020/06/12 20:36:52 [TRACE] Executing graph transform terraform.AttachStateTransformer 2020/06/12 20:36:52 [DEBUG] Resource instance state not found for node "google_composer_environment.dwh-composer-7te458r", instance google_composer_environment.dwh-composer-7te458r 2020/06/12 20:36:52 [TRACE] Completed graph transform terraform.AttachStateTransformer (no changes) 2020/06/12 20:36:52 [TRACE] Executing graph transform terraform.TargetsTransformer 2020/06/12 20:36:52 [TRACE] Completed graph transform terraform.TargetsTransformer (no changes) 2020/06/12 20:36:52 [TRACE] Executing graph transform terraform.ReferenceTransformer 2020/06/12 20:36:52 [DEBUG] ReferenceTransformer: "google_composer_environment.dwh-composer-7te458r" references: [] 2020/06/12 20:36:52 [TRACE] Completed graph transform terraform.ReferenceTransformer (no changes) 2020/06/12 20:36:52 [TRACE] Executing graph transform terraform.RootTransformer 2020/06/12 20:36:52 [TRACE] Completed graph transform terraform.RootTransformer (no changes) 2020/06/12 20:36:52 [TRACE] vertex "google_composer_environment.dwh-composer-7te458r": entering dynamic subgraph 2020/06/12 20:36:52 [TRACE] dag/walk: updating graph 2020/06/12 20:36:52 [TRACE] dag/walk: added new vertex: "google_composer_environment.dwh-composer-7te458r" 2020/06/12 20:36:52 [TRACE] dag/walk: visiting "google_composer_environment.dwh-composer-7te458r" 2020/06/12 20:36:52 [TRACE] vertex "google_composer_environment.dwh-composer-7te458r": starting visit (terraform.NodePlannableResourceInstance) 2020/06/12 20:36:52 [TRACE] vertex "google_composer_environment.dwh-composer-7te458r": evaluating 2020/06/12 20:36:52 [TRACE] [walkPlan] Entering eval tree: google_composer_environment.dwh-composer-7te458r 2020/06/12 20:36:52 [TRACE] : eval: terraform.EvalSequence 2020/06/12 20:36:52 [TRACE] : eval: terraform.EvalGetProvider 2020/06/12 20:36:52 [TRACE] : eval: terraform.EvalReadState 2020/06/12 20:36:52 [TRACE] EvalReadState: reading state for google_composer_environment.dwh-composer-7te458r 2020/06/12 20:36:52 [TRACE] EvalReadState: no state present for google_composer_environment.dwh-composer-7te458r 2020/06/12 20:36:52 [TRACE] : eval: terraform.EvalValidateSelfRef 2020/06/12 20:36:52 [TRACE] : eval: terraform.EvalDiff 2020/06/12 20:36:52 [TRACE] Re-validating config for "google_composer_environment.dwh-composer-7te458r" 2020/06/12 20:36:52 [TRACE] GRPCProvider: ValidateResourceTypeConfig 2020/06/12 20:36:52 [ERROR] : eval: *terraform.EvalDiff, err: 4 problems:

- "config.0.node_config.0.ip_allocation_policy.0.cluster_secondary_range_name": conflicts with config.0.node_config.0.ip_allocation_policy.0.cluster_ipv4_cidr_block

"config.0.node_config.0.ip_allocation_policy.0.services_secondary_range_name": conflicts with config.0.node_config.0.ip_allocation_policy.0.services_ipv4_cidr_block

Let me know if more info is needed on this.

On Fri, Jun 12, 2020 at 8:36 PM Edward Sun notifications@github.com wrote:

@kikuingithub https://github.com/kikuingithub can you post the debug log so I can take a close look?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-643323076, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSVKTGD63TQRQIKRAITRWI777ANCNFSM4N4HFKUA .

edwardmedia commented 4 years ago

@kikuingithub can you add steps to repro the issue?

kikuingithub commented 4 years ago

Nothing significant..!

terraform init .. plan.. apply. The resource declaration for google_composer_envoronment is included in the github issue details. I would also like to add that the terraform doc for the composer says that any two of the four attributes in the ip_allocation_policy block are required. But the actually, all four attribites are mandatory.

Thanks,

On Fri, Jun 12, 2020, 9:12 PM Edward Sun notifications@github.com wrote:

@kikuingithub https://github.com/kikuingithub can you add steps to repro the issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-643342168, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSRDWK5KMV2GJZYOPWTRWJEHNANCNFSM4N4HFKUA .

edwardmedia commented 4 years ago

@kikuingithub can you share the plan?

edwardmedia commented 4 years ago

The doc is correct, according to https://cloud.google.com/composer/docs/reference/rest/v1/projects.locations.environments#ipallocationpolicy. We should only accept two

kikuingithub commented 4 years ago

This will never take me to plan. The terraform execution stops with the ip_allocation conflict message which i have already posted.

On Fri, Jun 12, 2020 at 9:58 PM Edward Sun notifications@github.com wrote:

@kikuingithub https://github.com/kikuingithub can you share the plan?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-643370210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSQYOUDEP6AIHZKLU3LRWJJSPANCNFSM4N4HFKUA .

kikuingithub commented 4 years ago

Hi Edward, Hope you are doing well !!

Do you need any more information from me? I am happy to provide. Found that shared VPC is NOT supported by the V1 version of API, but it is implemented in v1beta1. Is this beta API version used in the latest terraform modules ?

Thanks !!

On Fri, Jun 12, 2020 at 10:25 PM Edward Sun notifications@github.com wrote:

The doc is correct, according to https://cloud.google.com/composer/docs/reference/rest/v1/projects.locations.environments#ipallocationpolicy

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-643382343, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSRUGQXX2D5KVHPMLOTRWJMYVANCNFSM4N4HFKUA .

emilymye commented 4 years ago

@kikuingithub May I ask where you see that all ip_allocation_policy attributes are required? From our docs and the GCP docs, you can only specify cluster or service IP addresses by one of _secondary_range_name or _ipv4_cidr_block inside this block. i.e. valid configs would be:

ip_allocation_policy {
  use_ip_aliases = true
  cluster_secondary_range_name = "..."
  service_secondary_range_name = "..."
}

or

ip_allocation_policy {
  use_ip_aliases = true
  cluster_ipv4_cidr_block = "..."
  service_ipv4_cidr_block = "..."
}

That's what the conflicting messages mean.

kikuingithub commented 4 years ago

Hi Edward,

Replying your previous query, ip_allocation_policy { cluster_ipv4_cidr_block = "" cluster_secondary_range_name = "name of range1" services_ipv4_cidr_block = "" services_secondary_range_name = "name of range 2" use_ip_aliases = true }

This is not liked by Terraform and throws the previous stated error that all fields are mandatory.

Can you please clear me if the current google_composer_environment terraform module supports composer environment with shared VPC (that implements v1beta1 of google rest API). Please provide me the versions of the module that would help me in understanding it better.

Thanks !!

On Mon, Jun 15, 2020 at 11:02 PM emily notifications@github.com wrote:

@kikuingithub https://github.com/kikuingithub May I ask where you see that ip_allocation_policy attributes are required? From our (docs)[ https://www.terraform.io/docs/providers/google/r/composer_environment.html] and the GCP docs https://cloud.google.com/composer/docs/reference/rest/v1/projects.locations.environments#ipallocationpolicy, you can only specify cluster or service IP addresses by one of _secondary_range_name or _ipv4_cidr_block inside this block. i.e. valid configs would be:

ip_allocation_policy { use_ip_aliases = true cluster_secondary_range_name = "..." service_secondary_range_name = "..." }

or

ip_allocation_policy { use_ip_aliases = true cluster_ipv4_cidr_block = "..." service_ipv4_cidr_block = "..." }

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-644270034, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSW2TUD2RLUPWMVKWB3RWZLMRANCNFSM4N4HFKUA .

emilymye commented 4 years ago

Hi @kikuingithub - I can't seem to find the error message you mentioned previously about all fields being mandatory. I only see the conflicts_with error message when you supply all four optional nested fields in ip_allocation_policy. Did you post a log with that message and the exact config?

Shared VPC (ip_allocation_policy fields) was added to the GA provider in 2.12.0 (marked as private environment config), so it actually is supported for both providers. The GKE (Container Cluster) v1beta1 API is the beta-only API

As an example of a working shared VPC config, I am able to successfully run this config on both the GA and beta provider. Note that the ip_allocation_policy has ONLY cluster_secondary_range_name and services_secondary_range_name specified.

resource "google_compute_network" "vpc" {
  name                    = "sharedvpc"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "vpc-sub" {
  name                     = google_compute_network.vpc.name
  network                  = google_compute_network.vpc.name
  ip_cidr_range            = "10.0.36.0/24"
  region                   = "us-central1"
  private_ip_google_access = true

  secondary_ip_range {
    range_name    = "pod"
    ip_cidr_range = "10.0.0.0/19"
  }

  secondary_ip_range {
    range_name    = "svc"
    ip_cidr_range = "10.0.32.0/22"
  }
}

resource "google_composer_environment" "test" {
  name   = "test-env"
  region = "us-central1"
  config {
    node_config {
      network    = google_compute_network.vpc.self_link
      subnetwork = google_compute_subnetwork.vpc-sub.self_link
      zone       = "us-central1-a"

      ip_allocation_policy {
        use_ip_aliases = true
        cluster_secondary_range_name = google_compute_subnetwork.test.secondary_ip_range[0].range_name
        services_secondary_range_name = google_compute_subnetwork.test.secondary_ip_range[1].range_name
      }
    }
  }
}

Based on the example given in the previous reply, you are still including cluster_ipv4_cidr_block and services_ipv4_cidr_block. Either you need to remove these two fields or add them and remove the secondary_range_name fields.

kikuingithub commented 4 years ago

Hi , In above example, can you try it with actual shared VPC, that is shared from a host project..

Yes, the conflict error is what i see when I give all the attribues in the IP_allocation_policy, it worked when i give only range names or address ranges. And now i am getting a new error. But when tried from Terraform getting below error. CREATE operation on this environment failed 51 minutes ago with the following error message: Http error status code: 400 Http error message: BAD REQUEST Additional errors: {"ResourceType":"serviceproject1/us-central1-dev-dwh-dwh-com-05e4dedf-addons-gke-typer:container.projects.zones.clusters.nodePools.setManagement","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"Cluster is currently being created, deleted, updated or repaired and cannot be updated.","status":"FAILED_PRECONDITION","details":[],"statusMessage":"Bad Request","requestPath":" https://container.googleapis.com/v1/projects/serviceproject1/zones/us-central1-b/clusters/us-central1-dev-dwh-dwh-com-05e4dedf-gke/nodePools/default-pool/setManagement ","httpMethod":"POST"}}

I am able to use shared VPC and create the composer environment from UI. Are you sure that the current terraform module supports Shared VPC.

Thanks,

On Tue, Jun 16, 2020 at 11:29 PM emily notifications@github.com wrote:

Hi @kikuingithub https://github.com/kikuingithub - I can't seem to find the error message you mentioned previously about all fields being mandatory. I only see the conflicts_with error message when you supply all four optional nested fields in ip_allocation_policy. Did you post a log with that message and the exact config?

Shared VPC (ip_allocation_policy fields) was added to the GA provider in 2.12.0 https://github.com/terraform-providers/terraform-provider-google/blob/master/CHANGELOG.md#2120-august-01-2019 (marked as private environment config), so it actually is supported for both providers. The GKE (Container Cluster) v1beta1 API is the beta-only API

As an example of a working shared VPC config, I am able to successfully run this config on both the GA and beta provider. Note that the ip_allocation_policy has ONLY cluster_secondary_range_name and services_secondary_range_name specified.

resource "google_compute_network" "vpc" { name = "sharedvpc" auto_create_subnetworks = false }

resource "google_compute_subnetwork" "vpc-sub" { name = google_compute_network.vpc.name network = google_compute_network.vpc.name ip_cidr_range = "10.0.36.0/24" region = "us-central1" private_ip_google_access = true

secondary_ip_range { range_name = "pod" ip_cidr_range = "10.0.0.0/19" }

secondary_ip_range { range_name = "svc" ip_cidr_range = "10.0.32.0/22" } }

resource "google_composer_environment" "test" { name = "test-env" region = "us-central1" config { node_config { network = google_compute_network.vpc.self_link subnetwork = google_compute_subnetwork.vpc-sub.self_link zone = "us-central1-a"

  ip_allocation_policy {
    use_ip_aliases = true
    cluster_secondary_range_name = google_compute_subnetwork.test.secondary_ip_range[0].range_name
    services_secondary_range_name = google_compute_subnetwork.test.secondary_ip_range[1].range_name
  }
}

} }

Based on the example given in the previous reply, you are still including cluster_ipv4_cidr_block and services_ipv4_cidr_block. Either you need to remove these two fields or add them and remove the secondary_range_name fields.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-644919723, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSRT2F5Y77DYAO4AICLRW6XJHANCNFSM4N4HFKUA .

emilymye commented 4 years ago

The error you got on creating the environment after 51 minutes actually looks like the creation API call succeeded but the Composer API returns an operation error because the underlying GKE cluster is being edited.

At this point, this is an upstream API error (i.e. a Composer issue, not a Terraform one) and likely a temporary timing issue. I can file a bug against the upstream API to handle issues like this better (they should wait on cluster updates if something else is happening concurrently to the cluster)

Otherwise, all we can really do is just try the same operation again. I understand it's very frustrating because it takes SO LONG, but this is a pretty complex resource that spins up several different GCP resources in the background and a lot of those background requests can fail and get returned as non-retryable errors by the Composer API. We encounter errors like this fairly regularly during our tests.

As for shared VPC support, support in the Terraform provider really means "can ip_allocation_policy be set". If you look at your debug logs, you should be able to see that the request is sent with the ip_allocation_policy fields, so we support shared VPC in both providers.

I'd also caution against using the word "module" to talk about the provider, since Terraform modules mean a very different thing than the provider.

kikuingithub commented 4 years ago

Hi,

Yes please .. do raise a bug against the upstream API and share the details here so that i can follow up on it.

Once again, Thanks for all your help !!

Thanks,

On Thu, Jun 18, 2020, 12:16 AM emily notifications@github.com wrote:

The error you got on creating the environment after 51 minutes actually looks like the creation API call succeeded but the Composer API returns an operation error because the underlying GKE cluster is being edited.

At this point, this is an upstream API error (i.e. a Composer issue, not a Terraform one) and likely a temporary timing issue. I can file a bug against the upstream API to handle issues like this better (they should wait on cluster updates if something else is happening concurrently to the cluster)

Otherwise, all we can really do is just try the same operation again. I understand it's very frustrating because it takes SO LONG, but this is a pretty complex resource that spins up several different GCP resources in the background and a lot of those background requests can fail and get returned as non-retryable errors by the Composer API. We encounter errors like this fairly regularly during our tests.

As for shared VPC support, support in the Terraform provider really means "can ip_allocation_policy be set". If you look at your debug logs, you should be able to see that the request is sent with the ip_allocation_policy fields, so we support shared VPC in both providers.

I'd also caution against using the word "module" to talk about the provider, since Terraform modules https://www.terraform.io/docs/modules/index.html mean a very different thing than the provider.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/terraform-providers/terraform-provider-google/issues/6579#issuecomment-645554432, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELFFSUOAL5W4XD4C34EKPLRXEFQZANCNFSM4N4HFKUA .

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!