Community

How to use self-uploaded image in Terraform

I try to load my own image (uploaded to Image Manger) in Terraform code like this:


resource "profitbricks_server" "webserver" {
    name         = "webserver"
    datacenter_id     = "${profitbricks_datacenter.main.id}"
    cores             = 1
    ram               = 1024
    availability_zone = "AUTO"
    cpu_family        = "AMD_OPTERON"
    volume {
        name       = "system"
        image_name = "_uuid_of_my_image_"
        size       = 60
        disk_type  = "HDD"
        availability_zone = "AUTO"
        image_password = "password"
    }
}

But it complains

  "httpStatus" : 422,
  "messages" : [ {
    "errorCode" : "100",
    "message" : "[(root).entities.volumes.items.[0].properties.image] Not a public Profitbricks image:_uuid_of_my_image_"
  }

Does this mean the self-uploaded images are not supported in Terraform-ProfitBricks provider?

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

Hello jsliu,

Have you tried omitting the image_password in the volume{} section?

As far as I know, passing in an image_password is only valid when using a ProfitBricks public image, so it seems that may be causing the issue.

Eric

  • Yes I've tried that way, in that case it will complain

    
    * profitbricks_server.nat_gateway: Either 'image_password' or 'ssh_key_path' must be provided.
    

Okay - it looks like you found a bug! I went ahead and opened an issue in the GitHub repository so that it can be addressed soon.

https://github.com/profitbricks/terraform-provider-profitbricks/issues/43

Thank you!

  • Ok, thanks for following this.

Here is the fix: https://github.com/profitbricks/terraform-provider-profitbricks/releases/tag/v1.2.4

If you were using ProfitBricks Terraform provider as third-party plugin you can use this version. If you were using ProfitBricks Provider as a builtin provider in Terraform we will have to wait for the next Terraform release.