displague / deprecated-terraform-provider-linode

[OLD] Terraform provider plugin for Linode Cloud resources.. See
https://github.com/terraform-providers/terraform-provider-linode
Mozilla Public License 2.0
15 stars 5 forks source link

initial images support #32

Closed akerl closed 5 years ago

akerl commented 5 years ago

This is about as bare bones as the feature could get, but I did use it to make an image. Still needs tests added, but curious if the rest of it looks sane. Would fix #8

resource "linode_instance" "foobaz" {
    root_pass = "3X4mp13"
    type = "g6-nanode-1"
    region = "us-west"
}

resource "linode_image" "foobar" {
    label = "foo-volume"
    description = "My new disk image"
    linode_id = "${linode_instance.foobaz.id}"
    disk_id = "${linode_instance.foobaz.disk.0.id}"

    lifecycle {
      prevent_destroy = true
    }
}
akerl commented 5 years ago

So, I'm having 2nd thoughts about this approach, or at least about this being the complete approach.

Imagine this flow (which is what I was working on):

  1. Terraform module creates Linode, and provisions it
  2. Terraform module creates Image from Linode's disk
  3. Terraform module wants to remove Linode, because it's now extraneous.

Doing this as-is would be hard (I'd basically have to use either a null_resource or a script that runs for Step 3 to blow up the Linode.

I considered doing it as an attribute of the Image, but then how do you attach provisioners to it?

I'm left thinking there needs to be some kind of "resource" for removing the Linode in step 3? But I'm not sure how I'd do it.