By joegasewicz
Hi,
I’m trying to achieve a setup whereby i can tear down a droplet and reattach it to a volume whenever i need to update code etc.
But after i re attach the volume to the droplet , all the data is gone. here is my config:
resource "digitalocean_volume" "main-api" {
region = "lon1"
name = "ms-vol-two"
size = 2
initial_filesystem_type = "ext4"
description = "File storage for postgres"
}
resource "digitalocean_droplet" "main-api" {
image = "docker-18-04"
name = "main-api"
region = "lon1"
size = "512mb"
private_networking = true
ssh_keys = [
var.ssh_fingerprint
]
... etc
}
resource "digitalocean_volume_attachment" "main-api" {
droplet_id = digitalocean_droplet.main-api.id
volume_id = digitalocean_volume.main-api.id
}
When i SSH into the droplet i /mnt/ms_vol_two exists but has no data. I can create data there and it saves normally. But when i destroy the main-api droplet and then re run with terraform apply the droplet only has /mnt/ms_vol_two but the data is no longer there…?
Thanks, Joe.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.