Skip to content
This repository was archived by the owner on Feb 1, 2019. It is now read-only.

Automatically create snapshots when destroying volumes - #33

Open
ivyleavedtoadflax wants to merge 10 commits into
masterfrom
feature/create_snapshots
Open

Automatically create snapshots when destroying volumes#33
ivyleavedtoadflax wants to merge 10 commits into
masterfrom
feature/create_snapshots

Conversation

@ivyleavedtoadflax

@ivyleavedtoadflax ivyleavedtoadflax commented Jan 18, 2018

Copy link
Copy Markdown
Contributor

Automatically create a snapshot of the mounted volume prior to destruction by setting the -c flag to 1:

./databox -c 1 down

This executes a "local-exec" provisioner and uses the aws command line to take a snapshot of the volume the moment before it is destroyed.

A json containing the snapshot id will be returned to console. This number should be recorded.

@ivyleavedtoadflax ivyleavedtoadflax changed the title [WIP] Automatically create snapshots when destroying volumes Automatically create snapshots when destroying volumes Jan 18, 2018
Comment thread main.tf

provisioner "local-exec" {
when = "destroy"
command = "if [ ${var.create_snapshot} ]; then aws ec2 create-snapshot --volume-id ${aws_ebs_volume.volume.id} --region ${var.aws_region} --profile ${var.profile} ; fi;"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreagrandi this checks whether anything has been assigned to var.create_snapshot, and if there is any string then it executes the command. This still needs you to set ./databox.sh -c 1 down, it would be nice if the 1 was not required and you could simply pass ./databox.sh -c down, but I could not get this to work. Any thoughts?

@ivyleavedtoadflax

Copy link
Copy Markdown
Contributor Author

@andreagrandi also propose we give this a tag of v0.1.0 (or similar) once this is merged. What do you think?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant