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

azurerm fails on updates, need to destroy all infrastructure every time I change something. #11

Closed
hashibot opened this issue Jun 13, 2017 · 2 comments
Labels

Comments

@hashibot
Copy link

This issue was originally opened by @noam87 as hashicorp/terraform#6735. It was migrated here as part of the provider split. The original body of the issue is below.


Hi, this config file was giving this error (and debug shown below):

Error applying plan:

1 error(s) occurred:

* azurerm_virtual_machine.core-build: Error waiting for Virtual Machine (cbvm) to become available: unexpected state 'Failed', wanted target '[Succeeded]'
  1. I got it to work by destroying then applying again.
  2. Next, I uncommented the "remote-exec" provisioner seen below, however I got all green with 0 changed.
  3. Finally, I destroyed and applyed again, and it worked.

The error always happens on the create stage. The VM that changed is destroyed successfully (it seems), but when it tries to recreate it, I'll get the error.

So there's something going on when applying updates where only the vm needs to recreate. So far I've had to destroy everything on every change I make, which is not sustainable for a production environment.

Terraform Version

0.6.16

Affected Resource(s)

azurerm_virtual_machine

Terraform Configuration Files

resource "azurerm_virtual_machine" "core-build" {
  name = "cbvm"
  location = "East US"
  resource_group_name = "${azurerm_resource_group.core-build.name}"
  network_interface_ids = ["${azurerm_network_interface.core-build.id}"]
  vm_size = "Standard_A0"

  storage_image_reference {
    publisher = "Canonical"
    offer = "UbuntuServer"
    sku = "14.04.2-LTS"
    version = "latest"
  }

  storage_os_disk {
    name = "myosdisk1"
    vhd_uri = "${azurerm_storage_account.core-build.primary_blob_endpoint}${azurerm_storage_container.core-build.name}/myosdisk1.vhd"
    caching = "ReadWrite"
    create_option = "FromImage"
  }

  os_profile {
    computer_name = "computer"
    admin_username = "admin"
    admin_password = "somepassword"
  }

  # Add SSH public keys from developers here
  os_profile_linux_config {
    disable_password_authentication = true

    ssh_keys {
      path = "/home/ekkoadmin/.ssh/authorized_keys"
      key_data = "${file("ssh_pub_keys/2014worktop.pub")}"
    }

    ssh_keys {
      path = "/home/ekkoadmin/.ssh/authorized_keys"
      key_data = "${file("ssh_pub_keys/2013tanktop.pub")}"
    }
  }

  connection {
    type = "ssh"
    host     = "${azurerm_public_ip.core-build.ip_address}"
    user     = "admin"
    private_key = "~/.ssh/id_rsa"
  }

  provisioner "file" {
    source = "bash_scripts/provision_build_vm.sh"
    destination = "/tmp/provision_build_vm.sh"
    connection {
      type = "ssh"
      host     = "${azurerm_public_ip.core-build.ip_address}"
      user     = "admin"
      private_key = "~/.ssh/id_rsa"
    }
  }

# provisioner "remote-exec" {
#   inline = [
#     "chmod +x /tmp/provision_build_vm.sh",
#     "/tmp/provision_build_vm.sh"
#   ]
#   connection {
#     host     = "${azurerm_public_ip.core-build.ip_address}"
#     user     = "admin"
#     key_file = "~/.ssh/id_rsa"
#   }
# }

  tags {
    environment = "build"
  }
}

Debug Output

https://gist.github.com/noam87/60bc0e429f08933f3fddd53caf8feade

@tombuildsstuff
Copy link
Contributor

Closing since no response in the original issue: hashicorp/terraform#6735 (comment)

@ghost
Copy link

ghost commented Apr 1, 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 Apr 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants