Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid planned change after resouce creation failure #27559

Closed
rvandegrift opened this issue Jan 21, 2021 · 1 comment · Fixed by #27563
Closed

invalid planned change after resouce creation failure #27559

rvandegrift opened this issue Jan 21, 2021 · 1 comment · Fixed by #27563
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue

Comments

@rvandegrift
Copy link

While troubleshooting hashicorp/terraform-provider-google#8261 I came upon a bug in terraform core. In that issue, a provider generates an invalid name for a resource. The google api rejects the creation.

If I apply again, terraform shows the failed resource as tainted, and exits with an invalid plan error.

Terraform Version

Terraform v0.14.4
+ provider registry.terraform.io/hashicorp/google v3.53.0
+ provider registry.terraform.io/hashicorp/google-beta v3.53.0

Terraform Configuration Files

variable "project" {
  type = string
}

provider "google" {
  project = var.project
}

provider "google-beta" {
  project = var.project
}

data "google_compute_network" "network" {
  name = "default"
}

data "google_compute_subnetwork" "subnet" {
  name   = "default"
  region = "us-central1"
}

resource "google_container_cluster" "cluster" {
  provider   = google-beta
  name       = "cluster-1"
  location   = "us-central1"
  network    = data.google_compute_network.network.self_link
  subnetwork = data.google_compute_subnetwork.subnet.self_link

  remove_default_node_pool = true
  node_pool {
    name       = "default-pool"
    node_count = 0
  }

  lifecycle {
    prevent_destroy = true

    ignore_changes = [
      node_pool,
      min_master_version,
    ]
  }
}


resource "google_container_node_pool" "nodes" {
  provider           = google-beta
  name_prefix        = "ca-nonprod-core-"
  location           = "us-central1"
  cluster            = google_container_cluster.cluster.name
  initial_node_count = 1

  node_config {
    machine_type = "n1-standard-4"
    disk_size_gb = 100
    image_type   = "COS_CONTAINERD"

    metadata = {
      disable-legacy-endpoints = "true"
    }

    oauth_scopes = [
      "https://www.googleapis.com/auth/logging.write",
      "https://www.googleapis.com/auth/monitoring",
      "https://www.googleapis.com/auth/devstorage.read_only",
    ]
  }

  lifecycle {
    create_before_destroy = true
  }
}

Debug Output

https://gist.github.com/rvandegrift/b9bc65e5d35c97b80890125e0ca27096

Expected Behavior

Terraform could continue. It wants to delete a resource that doesn't exist.

Actual Behavior

Terraform fails with:

Error: Invalid planned change

The plan contains a replace change for google_container_node_pool.nodes, which
doesn't exist yet. This is a bug in Terraform.

Steps to Reproduce

Additional Context

References

@rvandegrift rvandegrift added bug new new issue not yet triaged labels Jan 21, 2021
@jbardin jbardin self-assigned this Jan 21, 2021
@jbardin jbardin added confirmed a Terraform Core team member has reproduced this issue and removed new new issue not yet triaged labels Jan 21, 2021
@ghost
Copy link

ghost commented Feb 21, 2021

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants