Skip to content

Instantly share code, notes, and snippets.

@iamtheindian
Last active June 13, 2020 11:39
Show Gist options
  • Save iamtheindian/4a9becbd2fc1e6ea709e494884c46102 to your computer and use it in GitHub Desktop.
Save iamtheindian/4a9becbd2fc1e6ea709e494884c46102 to your computer and use it in GitHub Desktop.
#creation of ebs volume
resource "aws_ebs_volume" "myvol" {
depends_on =[aws_instance.webos]
availability_zone = aws_instance.webos.availability_zone
size = 1
tags = {
Name = "myvolume"
}
}
resource "aws_volume_attachment" "ebs_att" {
depends_on = [aws_ebs_volume.myvol]
device_name = "/dev/sdd"
volume_id = aws_ebs_volume.myvol.id
instance_id = aws_instance.webos.id
force_detach = true
}
/////////////////////////////////////////////////////
#create snapshot of aws ebs volume
resource "aws_ebs_snapshot" "snapshot" {
depends_on = [null_resource.nl1]
volume_id = "${aws_ebs_volume.myvol.id}"
tags = {
Name = "terraform ebs snap"
}
}
output "snapshot_id" {
value = aws_ebs_snapshot.snapshot.id
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment