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_image" gets recreated with every run #15773

Closed
spbreed opened this issue Aug 9, 2017 · 2 comments
Closed

"azurerm_image" gets recreated with every run #15773

spbreed opened this issue Aug 9, 2017 · 2 comments

Comments

@spbreed
Copy link

spbreed commented Aug 9, 2017

Terraform Version

Terraform v0.10.0

Terraform Configuration Files

resource "azurerm_image" "test" {
  name = "acctest"
  location = "East US 2"
  resource_group_name = "${azurerm_resource_group.test.name}"
  os_disk {
    os_type = "Linux"
    os_state = "Generalized"
    blob_uri = "https://pcsnonprodimages.blob.core.windows.net/system/Microsoft.Compute/Images/images/pcsnonprod-ubuntuv01-osDisk.6a65bac6-bc69-4785-948b-a419820c76f0.vhd"
    # size_gb = 30
  }
}

Debug Output

terraform apply

azurerm_resource_group.test: Creating...
  location: "" => "eastus2"
  name:     "" => "acctestrg"
  tags.%:   "" => "<computed>"
azurerm_resource_group.test: Creation complete (ID: /subscriptions/9bc818d2-70ea-4c3a-9677-0d312a2e5b65/resourceGroups/acctestrg)
azurerm_image.test: Creating...
  location:                           "" => "eastus2"
  name:                               "" => "acctest"
  os_disk.#:                          "" => "1"
  os_disk.3156744706.blob_uri:        "" => "https://pcsnonprodimages.blob.core.windows.net/system/Microsoft.Compute/Images/images/pcsnonprod-ubuntuv01-osDisk.6a65bac6-bc69-4785-948b-a419820c76f0.vhd"
  os_disk.3156744706.managed_disk_id: "" => "<computed>"
  os_disk.3156744706.os_state:        "" => "Generalized"
  os_disk.3156744706.os_type:         "" => "Linux"
  os_disk.3156744706.size_gb:         "" => "<computed>"
  resource_group_name:                "" => "acctestrg"
  tags.%:                             "" => "<computed>"
azurerm_image.test: Still creating... (10s elapsed)
azurerm_image.test: Still creating... (20s elapsed)
azurerm_image.test: Still creating... (30s elapsed)
azurerm_image.test: Still creating... (40s elapsed)
azurerm_image.test: Still creating... (50s elapsed)
azurerm_image.test: Still creating... (1m0s elapsed)
azurerm_image.test: Creation complete (ID: /subscriptions/9bc818d2-70ea-4c3a-9677-...iders/Microsoft.Compute/images/acctest)

terraform plan

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

azurerm_resource_group.test: Refreshing state... (ID: /subscriptions/9bc818d2-70ea-4c3a-9677-0d312a2e5b65/resourceGroups/acctestrg)
azurerm_image.test: Refreshing state... (ID: /subscriptions/9bc818d2-70ea-4c3a-9677-...iders/Microsoft.Compute/images/acctest)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

-/+ azurerm_image.test (new resource required)
      location:                           "eastus2" => "eastus2"
      name:                               "acctest" => "acctest"
      os_disk.#:                          "1" => "1"
      os_disk.2453480131.os_state:        "Generalized" => ""
      os_disk.2453480131.os_type:         "Linux" => ""
      os_disk.3156744706.blob_uri:        "" => "https://pcsnonprodimages.blob.core.windows.net/system/Microsoft.Compute/Images/images/pcsnonprod-ubuntuv01-osDisk.6a65bac6-bc69-4785-948b-a419820c76f0.vhd" (forces new resource)
      os_disk.3156744706.managed_disk_id: "" => "<computed>"
      os_disk.3156744706.os_state:        "" => "Generalized"
      os_disk.3156744706.os_type:         "" => "Linux"
      os_disk.3156744706.size_gb:         "" => "<computed>"
      resource_group_name:                "acctestrg" => "acctestrg"
      tags.%:                             "0" => "<computed>"


Plan: 1 to add, 0 to change, 1 to destroy.

TF state file

"primary": {
                        "id": "/subscriptions/9bc818d2-70ea-4c3a-9677-0d312a2e5b65/resourceGroups/acctestrg/providers/Microsoft.Compute/images/acctest",
                        "attributes": {
                            "data_disk.#": "0",
                            "id": "/subscriptions/9bc818d2-70ea-4c3a-9677-0d312a2e5b65/resourceGroups/acctestrg/providers/Microsoft.Compute/images/acctest",
                            "location": "eastus2",
                            "name": "acctest",
                            "os_disk.#": "1",
                            "os_disk.2453480131.blob_uri": "https://pcsnonprodimages.blob.core.windows.net/system/Microsoft.Compute/Images/images/pcsnonprod-ubuntuv01-osDisk.6a65bac6-bc69-4785-948b-a419820c76f0.vhd",
                            "os_disk.2453480131.caching": "None",
                            "os_disk.2453480131.managed_disk_id": "",
                            "os_disk.2453480131.os_state": "Generalized",
                            "os_disk.2453480131.os_type": "Linux",
                            "os_disk.2453480131.size_gb": "0",
                            "resource_group_name": "acctestrg",
                            "tags.%": "0"
                        },
                        "meta": {},
                        "tainted": false
                    },

Panic Output

Expected Behavior

Terraform plan should not recreate the resource

Actual Behavior

with every run image is deleted and recreated. refer "Debug Output" section

Steps to Reproduce

  1. terraform apply (to create iy for the first time)
  2. terraform plan or terraform apply -> recreates the image again

This in turn recreates the VM as Image_ID is referenced storage_image_reference

@hashibot
Copy link
Contributor

This issue has been automatically migrated to hashicorp/terraform-provider-azurerm#234 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to this issue and let us know.

@ghost
Copy link

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

No branches or pull requests

3 participants