After running Terraform plan, it tries to recreate it, which is something I don't want to do:
digitalocean_volume.volume: Refreshing state... [id=fbb475a4-ca1d-11ed-9d7b-0a58ac14d0b2]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# digitalocean_volume.volume must be replaced
-/+ resource "digitalocean_volume" "volume" {
~ droplet_ids = [] -> (known after apply)
~ filesystem_label = "pgsql_prod_data" -> (known after apply)
~ filesystem_type = "ext4" -> (known after apply)
~ id = "<ID of volume>" -> (known after apply)
+ initial_filesystem_label = "pgsql_prod_data" # forces replacement
+ initial_filesystem_type = "ext4" # forces replacement
name = "pgsql-prod-data"
tags = [
"prod",
]
~ urn = "do:volume:<ID of volume>" -> (known after apply)
# (2 unchanged attributes hidden)
}
Plan: 1 to add, 0 to change, 1 to destroy.
var.fs_label still contains the same value as before (pgsql_prod_data). When I comment the initial_filesystem_* attributes, the terraform plan reports no changes.
Affected Resource(s)
digitalocean_volume
Expected Behavior
Terraform plan should report no changes after import to state on digitalocean_volume
Actual Behavior
Terraform plan tries to recreated the volume, which is undesirable and causes lost of data in volume
Steps to Reproduce
>
1. Create a volume in Digital Ocean via CLI / UI
2. Import it to Terraform state with `initial_filesystem_*` attributes filled in, reflecting the resource made via console
3. Terraform plan wants to recreate volume.
**Terraform Configuration Files**
@phandox thanks for reporting this, after investigating the code I found that initial_filesystem_type and initial_filesystem_label are not set for new resources when reading them here. I will send a PR to fix this tomorrow after considering acceptance test for this.
Bug Report
Describe the bug
I had empty state and imported created digitalocean_volume via
terraform import digitalocean_volume.volume <ID>
.My definition of volume is this:
After running Terraform plan, it tries to recreate it, which is something I don't want to do:
var.fs_label
still contains the same value as before (pgsql_prod_data
). When I comment theinitial_filesystem_*
attributes, theterraform plan
reports no changes.Affected Resource(s)
digitalocean_volume
Expected Behavior
Terraform plan should report no changes after import to state on
digitalocean_volume
Actual Behavior
Terraform plan tries to recreated the volume, which is undesirable and causes lost of data in volume
Steps to Reproduce
> 1. Create a volume in Digital Ocean via CLI / UI 2. Import it to Terraform state with `initial_filesystem_*` attributes filled in, reflecting the resource made via console 3. Terraform plan wants to recreate volume. **Terraform Configuration Files**main.tf
variables.tf
Terraform version
Terraform - v1.3.9 digitalocean provider - v2.26.0
Debug Output
Panic Output
Additional context
Important Factoids
References