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

image should not be required for incus_instance #42

Open
stgraber opened this issue Mar 11, 2024 · 3 comments
Open

image should not be required for incus_instance #42

stgraber opened this issue Mar 11, 2024 · 3 comments
Labels
Bug Confirmed to be a bug Easy Good for new contributors

Comments

@stgraber
Copy link
Member

Instances can be created with an empty image, this is particularly useful for VMs.

@maveonair maveonair added Easy Good for new contributors Feature New feature, not a bug labels May 27, 2024
@sysadminsavage
Copy link

Another issue i found is when I import my existing incus containers into Terraform it then requires the "image" argument to do anything.

$ terraform plan
 Error: Missing required argument
The argument "image" is required, but no definition was found.

And if i do define the image, the terraform incus provider wants to force a replacement of the container.. (even though i've defined the same image that was used to deploy the container manually).
For example-

$ incus image launch images:debian/trixie pihole --network macvlan
$ terraform import incus_instance.pihole pihole
Import successful!
$ terraform plan
  # incus_instance.pihole must be replaced
-/+ resource "incus_instance" "pihole" {
      + image            = "images:debian/trixie" # forces replacement
      ~ ipv4_address     = "192.168.20.144" -> (known after apply)
      ~ ipv6_address     = "fe80::216:3eff:fe59:b91a" -> (known after apply
      ~ mac_address      = "00:16:3e:59:b9:1a" -> (known after apply)
        name             = "pihole"
      ~ profiles         = [
          ~ "default" -> "macvlan",
        ]
      ~ status           = "Running" -> (known after apply)
      + target           = (known after apply)
        # (7 unchanged attributes hidden)

      - device {
          - name       = "eth0" -> null
          - properties = {
              - "name"    = "eth0"
              - "network" = "macvlan"
            } -> null
          - type       = "nic" -> null
        }
    }

@maveonair
Copy link
Member

maveonair commented Jun 13, 2024

Another issue i found is when I import my existing incus containers into Terraform it then requires the "image" argument to do anything.

$ terraform plan
 Error: Missing required argument
The argument "image" is required, but no definition was found.

And if i do define the image, the terraform incus provider wants to force a replacement of the container.. (even though i've defined the same image that was used to deploy the container manually). For example-

$ incus image launch images:debian/trixie pihole --network macvlan
$ terraform import incus_instance.pihole pihole
Import successful!
$ terraform plan
  # incus_instance.pihole must be replaced
-/+ resource "incus_instance" "pihole" {
      + image            = "images:debian/trixie" # forces replacement
      ~ ipv4_address     = "192.168.20.144" -> (known after apply)
      ~ ipv6_address     = "fe80::216:3eff:fe59:b91a" -> (known after apply
      ~ mac_address      = "00:16:3e:59:b9:1a" -> (known after apply)
        name             = "pihole"
      ~ profiles         = [
          ~ "default" -> "macvlan",
        ]
      ~ status           = "Running" -> (known after apply)
      + target           = (known after apply)
        # (7 unchanged attributes hidden)

      - device {
          - name       = "eth0" -> null
          - properties = {
              - "name"    = "eth0"
              - "network" = "macvlan"
            } -> null
          - type       = "nic" -> null
        }
    }

The correct import command would be:

$ terraform import incus_instance.pihole default/pihole,image=images:debian/trixie

The reason for this is that our entire import logic works in this way. That is, you would have to pass all the important fields to the import command. I know this is not the most convenient way, but this is how our current import logic works across all resources.

@sysadminsavage
Copy link

The correct import command would be:

$ terraform import incus_instance.pihole default/pihole,image=images:debian/trixie

The reason for this is that our entire import logic works in this way. That is, you would have to pass all the important fields to the import command. I know this is not the most convenient way, but this is how our current import logic works across all resources.

that's perfectly fine - thanks for the clarification. i missed that.

@stgraber stgraber added Bug Confirmed to be a bug and removed Feature New feature, not a bug labels Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed to be a bug Easy Good for new contributors
Development

No branches or pull requests

3 participants