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 resource usage: 'Instance should be in the STOPPED state.' #7101

Closed
ItsMattL opened this issue Aug 25, 2020 · 2 comments · Fixed by GoogleCloudPlatform/magic-modules#3918, #7132 or hashicorp/terraform-provider-google-beta#2436
Assignees
Labels

Comments

@ItsMattL
Copy link

ItsMattL commented Aug 25, 2020

Terraform Version

2.20.2

Affected Resource(s)

  • google_compute_instance

Terraform Configuration Files (if applicable)

resource "google_compute_instance" "windows_vm" {
        allow_stopping_for_update = true
        can_ip_forward            = false
        cpu_platform              = "Intel Haswell"
        deletion_protection       = false
        enable_display            = false
        guest_accelerator         = []
        id                        = "..."
        instance_id               = "..."
        label_fingerprint         = "..."
        labels                    = {}
        machine_type              = "e2-standard-4"
        metadata                  = {}
        metadata_fingerprint      = "..."
        name                      = "..."
        project                   = "..."
        self_link                 = "https://www.googleapis.com/compute/v1/projects/.../zones/us-central1-f/instances/..."
        tags                      = []
        tags_fingerprint          = "..."
        zone                      = "us-central1-f"
        boot_disk {
            auto_delete = true
            device_name = "persistent-disk-0"
            mode        = "READ_WRITE"
            source      = "https://www.googleapis.com/compute/v1/projects/.../zones/us-central1-f/disks/..."
            initialize_params {
                image  = "https://www.googleapis.com/compute/v1/projects/.../global/images/windows-2016"
                labels = {}
                size   = 50
                type   = "pd-standard"
            }
        }
        network_interface {
            name               = "nic0"
            network            = "https://www.googleapis.com/compute/v1/projects/.../global/networks/default"
            network_ip         = "..."
            subnetwork         = "https://www.googleapis.com/compute/v1/projects/.../regions/us-central1/subnetworks/default"
            subnetwork_project = "..."
        }
        scheduling {
            automatic_restart   = true
            on_host_maintenance = "MIGRATE"
            preemptible         = false
        }
       shielded_instance_config {
            enable_integrity_monitoring = true
            enable_secure_boot          = true
            enable_vtpm                 = true
        }
    }

Issue Description

When creating new compute instances using Windows images and shielded_instance_configured, the instance is successfully created, but Terraform fails when trying to fully apply the shielded_instance_config settings.

Error updating shielded vm config: googleapi: Error 400: Invalid resource usage: 'Instance should be in the STOPPED state.'

If the instance is manually stopped post-creation, Terraform completes successfully, but it fails to stop the VM on its own, and will repeatedly fail until a human intervenes. enable_secure_boot is identified as the parameter that requires changing.

Important Factoids

  • This configuration worked up until recently (past few weeks), suggesting either the provider changed or the API did.
@edwardmedia edwardmedia self-assigned this Aug 26, 2020
@edwardmedia
Copy link
Contributor

edwardmedia commented Aug 26, 2020

@ghost
Copy link

ghost commented Sep 27, 2020

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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.