Community

Custom Image not found during exec terraform script

We have some problem creating a datacenter with terraform scripts. If we used ProfitBricks Images like "ubuntu-16.04", it's all fine. But if we used custom images, we uploaded to the same datacenter location, we get the error that the image cannot found. Have anyone a idea whats here the problem? Is it possible to use custom images in terraform scripts? We have successful used the custom image creating a Volume in the DCD.

Could not find an image/imagealias/snapshot that matches BaseImage_16_04

resource "profitbricks_server" "testserver01" {
  name              = "testserver01"
  datacenter_id     = "${profitbricks_datacenter.datacenter01.id}"
  cores             = 4
  ram               = 16384
  availability_zone = "AUTO"
  cpu_family        = "AMD_OPTERON"

  volume {
    name           = "system_volume-01"
    image_name     = "BaseImage_16_04"
    size           = 10
    disk_type      = "HDD"
    ssh_key_path   = ["${var.public_key_path}", "${var.public_key_path_intern}"]
    image_password = "${var.volume_password}"
  }

  nic {
    ....
  }
}

Thanks Michael

 
  • **bold**
  • _italics_
  • `code`
  • ```code block```
  • # Heading 1
  • ## Heading 2
  • > Quote
 

As a follow-up to my previous post. It looks like the situation you ran into was addressed in v1.4.0 which was released recently. You should be able to upgrade to the latest release of the ProfitBricks provider by running:

terraform init -upgrade

If there are still issues using your private image after confirming you are running the latest version of the provider, post here and someone can look into it further.

Hi Michael - I'm curious about this as well and will check into support for using private images by name in the Terraform module.

In the meantime, did you happen to try provisioning using the private image's ID instead of name? The Cloud API can be used to locate the image's ID with a call like this:

https://api.profitbricks.com/cloudapi/v4/images?depth=1&filter.public=false&filter.name=BaseImage&filter.location=us/las

You would need to make sure the name and location you are searching for match your requirements, or omit those filters and parse the potentially larger list of results manually.

The JSON results returned should contain a value for "id": like in this truncated example:

{
"id": "images",
"type": "collection",
"href": "https://api.profitbricks.com/cloudapi/v4/images",
"items": [
    {
        "id": "c32f1873-502a-11e5-bfc6-52540066fee9",
        "type": "image",
        "href": "https://api.profitbricks.com/cloudapi/v4/images/c32f1873-502a-11e5-bfc6-52540066fee9",

Then you would set the value for image_name to c32f1873-502a-11e5-bfc6-52540066fee9 in your Terraform configuration file.

Eric

Thanks for all answers. The problem to support custom images was a bug and it was solved with ProfitBricks Provider Version >= 1.4.0.