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: terraform-provider-incus provider fails to create the instance in the project not equal to "default" if image fingerprint assigned to image attribute instead of `image name #94

Closed
tregubovav-dev opened this issue Jun 28, 2024 · 2 comments · Fixed by #100

Comments

@tregubovav-dev
Copy link

tregubovav-dev commented Jun 28, 2024

Issue

[Description was rewritten on July 7, 2024 after addition investigation]
terraform-provider-incus provider fails to create the instance in the project not equal to "default" if image fingerprint assigned to image attribute instead of image name. Instance creation fails in this case with message like below:

incus_instance.test: Creating...
╷
│ Error: Failed to retrieve image info for instance "test"
│
│   with incus_instance.test,
│   on install_via_image.tf line 20, in resource "incus_instance" "test":
│   20: resource "incus_instance" "test" {
│
│ Image not found

Steps to reproduce

Failed configuration

terraform {
  required_providers {
    incus = {
      source = "lxc/incus"
      version = "0.1.2"
    }
  }
}

provider "incus" {
}

resource "incus_image" "alpine" {
    source_remote       = "images"
    source_image        = "alpine/3.18"
    aliases             = ["alpine-3.18"]
    project             = "test"
}

resource "incus_instance" "test" {
    name        = "test"
    image       = incus_image.alpine.fingerprint
    project     = "test"
}

Working configurations

terraform {
  required_providers {
    incus = {
      source = "lxc/incus"
      version = "0.1.2"
    }
  }
}

provider "incus" {
}

resource "incus_image" "alpine" {
    source_remote       = "images"
    source_image        = "alpine/3.18"
    aliases             = ["alpine-3.18"]
    project             = "default"
}

resource "incus_instance" "test" {
    name        = "test"
    image       = incus_image.alpine.fingerprint
    project     = "default"
}

OR

terraform {
  required_providers {
    incus = {
      source = "lxc/incus"
      version = "0.1.2"
    }
  }
}

provider "incus" {
}

resource "incus_image" "alpine" {
    source_remote       = "images"
    source_image        = "alpine/3.18"
    aliases             = ["alpine-3.18"]
}

resource "incus_instance" "test" {
    name        = "test"
    image       = incus_image.alpine.fingerprint
}

incus_image documentation shows how to use 'incus_instance' with 'incus_image` resource. However it does not work.

I also tried to assign short or long hardcoded 'fingerprint' value of existing image getting by command incus image list --project test with the same result.

terraform-provider-lxd has the same issue.

@tregubovav-dev tregubovav-dev changed the title Bug: incus_instance resources creation fails if fingerprint is used in image attribute instead of image name Bug: incus_instance resources creation fails if fingerprint is used in image attribute instead of image name and project is not equal to "default" Jul 2, 2024
@tregubovav-dev tregubovav-dev changed the title Bug: incus_instance resources creation fails if fingerprint is used in image attribute instead of image name and project is not equal to "default" Bug: incus_instance provider fail to create the instance in the project not equal to "default" if image fingerprint assigned to image attribute instead of `image name Jul 2, 2024
@tregubovav-dev tregubovav-dev changed the title Bug: incus_instance provider fail to create the instance in the project not equal to "default" if image fingerprint assigned to image attribute instead of `image name Bug: terraform-provider-incus provider fails to create the instance in the project not equal to "default" if image fingerprint assigned to image attribute instead of `image name Jul 2, 2024
@tregubovav-dev
Copy link
Author

Below is a workaround:

Modifying image attribute in incus_instance resource from image = incus_image.alpine.fingerprint to image = format("${incus_cached_image.alpine.source_remote}:${incus_cached_image.alpine.fingerprint}") makes the configuration work.
But, it's still not clear why image remote is required to create instance from cached image.

@tregubovav-dev
Copy link
Author

tregubovav-dev commented Jul 4, 2024

The LXD team fixed and closed the same bug in terraform-provider-lxd already. I would suggest to merge the same fix to the terraform-provider-incus

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