-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 #234
Comments
I think this is a duplicate of #224, I am looking into the issue (unable to reproduce, requested additional info). |
Seems to be fixed #224. Requires validation |
I'm still able to reproduce this issue. Here is my resource "azurerm_image" "test" {
name = "myimgname"
location = "West US"
resource_group_name = "myresourcegroup"
os_disk {
os_type = "Linux"
os_state = "Generalized"
blob_uri = "https://myblobaccount.blob.core.windows.net/osimage/xenial-server-cloudimg-amd64-disk1.vhd"
}
} And here is the output. First create a new resource: $ terraform apply
azurerm_image.test: Creating...
location: "" => "westus"
name: "" => "myimgname"
os_disk.#: "" => "1"
os_disk.1842404614.blob_uri: "" => "https://myblobaccount.blob.core.windows.net/osimage/xenial-server-cloudimg-amd64-disk1.vhd"
os_disk.1842404614.caching: "" => "None"
os_disk.1842404614.managed_disk_id: "" => "<computed>"
os_disk.1842404614.os_state: "" => "Generalized"
os_disk.1842404614.os_type: "" => "Linux"
os_disk.1842404614.size_gb: "" => "<computed>"
resource_group_name: "" => "myresourcegroup"
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 after 1m7s (ID: /subscriptions/2085065b-00f8-4cba-9675-...crosoft.Compute/images/myimgname)
Apply complete! Resources: 1 added, 0 changed, 0 destroyed. Then run the $ 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_image.test: Refreshing state... (ID: /subscriptions/2085065b-00f8-4cba-9675-...crosoft.Compute/images/myimgname)
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ azurerm_image.test (new resource required)
id: "/subscriptions/2085065b-00f8-4cba-9675-ba15f4d4ab66/resourceGroups/junyiacctestRG/providers/Microsoft.Compute/images/myimgname" => <computed> (forces new resource)
location: "westus" => "westus"
name: "myimgname" => "myimgname"
os_disk.#: "1" => "1"
os_disk.1807029459.caching: "None" => ""
os_disk.1807029459.os_state: "Generalized" => ""
os_disk.1807029459.os_type: "Linux" => ""
os_disk.1842404614.blob_uri: "" => "https://myblobaccount.blob.core.windows.net/osimage/xenial-server-cloudimg-amd64-disk1.vhd" (forces new resource)
os_disk.1842404614.caching: "" => "None"
os_disk.1842404614.managed_disk_id: "" => <computed>
os_disk.1842404614.os_state: "" => "Generalized"
os_disk.1842404614.os_type: "" => "Linux"
os_disk.1842404614.size_gb: "" => <computed>
resource_group_name: "myresourcegroup" => "myresourcegroup"
tags.%: "0" => <computed>
Plan: 1 to add, 0 to change, 1 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run. And my terraform version is: $ terraform --version
Terraform v0.10.8-dev (5fb1fe9de8ca3c4655ddd25098c7e486caae9a2a) |
Hey, This issue can now be addressed with using datasource for azurerm_image. Here is the example that shows how to use the new data source. Using the data source for Resourcedata "azurerm_resource_group" "image" { Using the data source for Image.data "azurerm_image" "image" { By using data source you can reference existing images that need not be recreated every time. |
@spbreed, Does this solve your issue? |
@VaijanathB How can we stop the |
Hello Pmarques, Can you please provide the tf script that you are trying out. Ideally you use data source if you already have an image and do not want to create the resource in your tf script. Having said that, once you have an azurerm_image resource, it should be idempotent provided all the properties evaluate the same. If you have an example where this is not happening, please update this thread with your tf script. Thanks, |
@VaijanathB My script just an example from Terraform, you can pick the most simple example for azurerm_image, the resource is not idempotent unless you set the ignore_changes #224 (comment). However this issue seems to be "fixed" #224 |
i can confirm that i still have this problem.
|
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! |
This issue was originally opened by @spbreed as hashicorp/terraform#15773. It was migrated here as a result of the provider split. The original body of the issue is below.
Terraform Version
Terraform v0.10.0
Terraform Configuration Files
Debug Output
terraform apply
terraform plan
TF state file
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
terraform apply
(to create iy for the first time)terraform plan
orterraform apply
-> recreates the image againThis in turn recreates the VM as Image_ID is referenced
storage_image_reference
The text was updated successfully, but these errors were encountered: