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

Copy snapshot to a different region #1008

Open
ddosia opened this issue Jul 15, 2023 · 1 comment
Open

Copy snapshot to a different region #1008

ddosia opened this issue Jul 15, 2023 · 1 comment

Comments

@ddosia
Copy link

ddosia commented Jul 15, 2023

Is your feature request related to a problem? Please describe.

I do a snapshot of a droplet through automation. This snapshot is a golden image to be used to create another droplets. I want this snapshot to be available in other regions.
Can't find a way to do it through terraform.

Describe the solution you'd like

# 1. Find existing snapshot through data source:
data "digitalocean_droplet_snapshot" "golden_last" {
  name_regex  = "^golden"
  region      = "fra1"
  most_recent = true
}

# 2. Using snapshot resource create in every other specified region:
resource "digitalocean_droplet_snapshot" "goldent_copy" {
  id      = data.digitalocean_droplet_snapshot.golden_last.id
  name    = data.digitalocean_droplet_snapshot.golden_last.name
  regions = ["nyc3", "sfo3"]
}

Describe alternatives you've considered

I found not very straightforward way to do it through doctl:

doctl compute image-action transfer --region nyc3 <existing droplet snapshot id>
doctl compute image-action transfer --region sfo3 <existing droplet snapshot id>

It's not clear because at least from API docs and Web Panel point droplet snapshots are neither images nor volume snapshots. But despite that you can use "image" API to transfer it to a different region.

Also I found a way to do this with packer (which is good but I'd still need terraform support since region list is dynamically changed through terraform):

# base.pkr.hcl
source "digitalocean" "golden" {
  region             = "fra1"
...
  snapshot_regions   = ["nyc3", "sfo3"]
}

build {
...
  sources = ["source.digitalocean.golden"]
...
}

If I miss something would appreciate your help.

@mikeberezowski
Copy link

Thank you for bringing this to our attention. There is one additional caveat you should be aware of. When working with images once you have them in multiple regions if you delete the image it will delete that image from all regions. This might be okay for your use case.

We encourage you to continue with the work around as Packer is a better choice for managing images. We will look to prioritize implementing the transfer action for images when we can.

Thanks again for your continued use and support of DigitalOcean's Terraform provider.

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

No branches or pull requests

3 participants