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

Is there any way to use snapshot as an image of hcloud server? #10

Open
JenkinsRyzum opened this issue Sep 1, 2023 · 2 comments
Open

Comments

@JenkinsRyzum
Copy link

Hi there,

First of all, thanks for your work with maintaining this plugin. I am quite new to Hetzner Cloud and would like to know if there any way to use snapshots as an image of the server, using your plugin?

@marco-m
Copy link

marco-m commented Jan 14, 2024

Hello,
I haven't tried yet, but it should be possible by passing the snapshot ID (which is an integer) as a string to the parameter hcloud_image of this plugin.

This "gotcha" is not specific to this plugin: also if you were to use just Terraform, you would need a way to find the ID, because the name works only for Hetzner-provided images, not for user snapshots.

For example, I use Packer to build snapshots, and use a label like this:

  source "hcloud.cfg" {
    name = "core"
    snapshot_name = "myimage"
    snapshot_labels = {
      "name" : "myimage" <== HERE
    }
  }

just to be able then in Terraform to find it as:

data "hcloud_image" "myimage" {
  with_selector = "name=myimage" <== looking up the label above
}

and finally pass the ID to construct a server:

resource "hcloud_server" "foo" {
  image              = data.hcloud_image.myimage.id  <== SEE `id`
  ...

Exact same reasoning if using Pulumi.

Note that you do not need to pass via Packer. Also if you took the snapshot from the webconsole, you could add a label and then use the same Terraform (or Pulumi) logic to find it.

@AndrewChubatiuk
Copy link
Owner

will add implementation later or feel free to submit your implementation in a PR

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

No branches or pull requests

3 participants