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

[BUG] Modifying a VM resource always fails if name (an argument marked optional) is omitted or does not look like a "DNS name" #42

Open
fabacab opened this issue Sep 9, 2020 · 1 comment

Comments

@fabacab
Copy link

fabacab commented Sep 9, 2020

This is basically the same issue as that described in #41 except instead of pool_id, the resource cannot be modified without a name argument (which is also marked as optional in this provider's documentation).

Here's the error:

Error: Received an HTTP 400 response - Reason: Parameter verification failed. (name: invalid format - value does not look like a valid DNS name)

To Reproduce

  1. Set up a single-node Proxmox VE cluster (6.2-11 is what I'm using, the current stable release).
  2. Create a simple, test VM with the following Terraform version 0.13.2 configuration (provider block is omitted for brevity):
    data "proxmox_virtual_environment_nodes" "pve_nodes" {}
    
    resource "proxmox_virtual_environment_file" "ubuntu_cloud_image" {
      content_type = "iso"
      datastore_id = "local"
      node_name    = data.proxmox_virtual_environment_nodes.pve_nodes.names[0]
    
      source_file {
        path = "https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"
      }
    }
    
    resource "proxmox_virtual_environment_vm" "testvm" {
      # Note that the `name` argument is commented out during VM creation.
      #name      = "must-be-here-to-modify-the-vm"
      node_name  = data.proxmox_virtual_environment_nodes.pve_nodes.names[0]
    
      disk {
        datastore_id = "local-lvm"
        file_id      = proxmox_virtual_environment_file.ubuntu_cloud_image.id
      }
    }
  3. Apply the Terraform configuration with terraform apply; it should succeed.
  4. However, now edit the Terraform config to make any non-destructive change such as adding (or removing) a network_device block without uncommenting the ostensibly optional name argument.
  5. Run terraform apply again, and observe the error cited above.

Expected behavior

  1. The documentation correctly describes the name value as a required argument, because it currently is. Or, preferably,
  2. the provider does not allow creating a VM resource without a name argument for a proxmox_virtual_environment_vm since this situation will always result in a resource that can never be edited, only destroyed, once created.
blz-ea added a commit to blz-ea/terraform-provider-proxmox that referenced this issue Dec 17, 2020
- Fix danitso#41
- Fix danitso#42
- Fix issues when `vm` resource is created without `initialization` block. Related to danitso#42

VM resource created without `initialization` block does not correctly set `initialization` block state attributes

## To Reproduce
1. Create a VM
```hcl
resource "proxmox_virtual_environment_vm" "testvm" {
  node_name   = "<your_node_name>"
  pool_id     = "<existing_pool>" # required due to danitso#41
}
```
2. `terraform apply`
3. `terraform plan`
```hcl
  # proxmox_virtual_environment_vm.testvm must be replaced
-/+ resource "proxmox_virtual_environment_vm" "testvm" {
        acpi                    = true
        bios                    = "seabios"
      ~ id                      = "103" -> (known after apply)
      ~ ipv4_addresses          = [] -> (known after apply)
      ~ ipv6_addresses          = [] -> (known after apply)
        keyboard_layout         = "en-us"
      ~ mac_addresses           = [] -> (known after apply)
      ~ network_interface_names = [] -> (known after apply)
        node_name               = "pve"
        pool_id                 = "pve"
        started                 = true
        tablet_device           = true
        template                = false
        vm_id                   = -1

      - initialization {
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.
```
@danitso-dp
Copy link
Collaborator

@fabacab do you still experience this issue with the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants