Skip to content

outscale_vm : adding a block_device_mappings forces replacement even on non-root volumes #513

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

Closed
zeylos opened this issue Mar 3, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@zeylos
Copy link

zeylos commented Mar 3, 2025


name: Bug report
about: adding a block_device_mappings forces replacement even on non-root volumes
labels: bug, new


Hello,

I have an issue with block_device_mappings which is whenever I try to add or remove a non-root block_device from the list terraform tries to recreate the machine.

Terraform Version

OpenTofu v1.9.0
on linux_amd64
+ provider registry.opentofu.org/outscale/outscale v1.0.0

Terraform Configuration Files

resource "outscale_vm" "xxx" {
    image_id = "ami-xxxx"
    vm_type = "tinav5.c1r1p2"
    subnet_id          = xxx
    private_ips        = [xxx]
    block_device_mappings {
        device_name = "/dev/sda1" # /
        bsu {
            volume_size = 10
            volume_type = "gp2"
        }
    }
    block_device_mappings {
        device_name = "/dev/xvdb"
        bsu {
            volume_size = 4
            volume_type = "gp2"
        }
    }
    block_device_mappings {         <<<<<<< this one was added after the vm was created
        device_name = "/dev/xvdc"
        bsu {
            volume_size = 4
            volume_type = "gp2"
        }
    }
}

### Output

  # outscale_vm.xxx must be replaced
-/+ resource "outscale_vm" "xxx" {
      ~ block_device_mappings_created  = [
          - {
              - bsu         = [
                  - {
                      - delete_on_vm_deletion = false
                      - link_date             = "2025-03-03T11:48:58.828Z"
                      - state                 = "attached"
                      - tags                  = []
                      - volume_id             = "vol-7d918f81"
                    },
                ]
              - device_name = "/dev/sda1"
            },
          - {
              - bsu         = [
                  - {
                      - delete_on_vm_deletion = false
                      - link_date             = "2025-03-03T11:48:58.828Z"
                      - state                 = "attached"
                      - tags                  = []
                      - volume_id             = "vol-c7ab9b29"
                    },
                ]
              - device_name = "/dev/xvdb"
            },
        ] -> (known after apply)
.....
      ~ block_device_mappings {
            # (1 unchanged attribute hidden)

          - bsu {
              - delete_on_vm_deletion = false -> null
              - iops                  = 0 -> null
              - volume_size           = 10 -> null
              - volume_type           = "gp2" -> null
            }
          + bsu {
              + delete_on_vm_deletion = (known after apply)
              + volume_size           = 10
              + volume_type           = "gp2"
            }
        }
      ~ block_device_mappings {
            # (1 unchanged attribute hidden)

          - bsu {
              - delete_on_vm_deletion = false -> null
              - iops                  = 0 -> null
              - volume_size           = 4 -> null
              - volume_type           = "gp2" -> null
            }
          + bsu {
              + delete_on_vm_deletion = (known after apply)
              + volume_size           = 4
              + volume_type           = "gp2"
            }
        }
      + block_device_mappings {
          + device_name = "/dev/xvdc" # forces replacement

          + bsu { # forces replacement
              + delete_on_vm_deletion = (known after apply)
              + volume_size           = 4
              + volume_type           = "gp2"
            }
        }
....

Expected Behavior

I would expect modifying only the device which has device_name "/dev/xvdc" in my case.

Actual Behavior

Terraform tries to modify all the volumes and recreate the instance.

Steps to Reproduce

provider "outscale" {
# bla
}
resource "outscale_vm" "xxx" {
    image_id = "xxx"
    vm_type = "tinav5.c1r1p2"
    subnet_id          = xxx
    private_ips        = ["xxx"]
    block_device_mappings {
        device_name = "/dev/sda1" # /
        bsu {
            volume_size = 10
            volume_type = "gp2"
        }
    }
    block_device_mappings {
        device_name = "/dev/xvdb"
        bsu {
            volume_size = 4
            volume_type = "gp2"
        }
    }
#   block_device_mappings {                          # apply one time then uncomment and apply again
#       device_name = "/dev/xvdc"
#       bsu {
#           volume_size = 4
#           volume_type = "gp2"
#       }
#   }
}

Additional Context

References

@zeylos zeylos added the bug Something isn't working label Mar 3, 2025
@outscale-toa
Copy link
Member

outscale-toa commented Mar 3, 2025

Hi @zeylos,

Updating/adding additional block_device_mappings to an existing VM is not possible actually with our terraform plugin.
This will come with the hot volume update ref #200 , #310

In your case, you can use the outscale_volume_link resource.

....
resource "outscale_volume_link" "volume_link01" {
    device_name = "/dev/xvdc"
    volume_id   = outscale_volume.volume01.volume_id
    vm_id       = outscale_vm.vm01.vm_id
}
....

Best regards,

@zeylos
Copy link
Author

zeylos commented Mar 3, 2025

Hi,

Thanks for the quick answer, I found #200 but I thought it was unrelated, sorry.

Regards,

@zeylos zeylos closed this as completed Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants