Skip to main content

Lab 10: Create Snapshot Using Terraform

The Nautilus DevOps team has some volumes in different regions in their AWS account. They are going to setup some automated backups so that all important data can be backed up on regular basis. For now they shared some requirements to take a snapshot of one of the volumes they have.

Create a snapshot of an existing volume named xfusion-vol in us-east-1 region using terraform.

  1. The name of the snapshot must be xfusion-vol-ss.

  2. The description must be Xfusion Snapshot.

  3. Make sure the snapshot status is completed before submitting the task.

    The Terraform working directory is /home/bob/terraform. Create the main.tf file (do not create a different .tf file) to provision the instance.

Note: Right-click under the EXPLORER section in VS Code and select Open in Integrated Terminal to launch the terminal.

Create main.tf

resource "aws_ebs_snapshot" "xfusion-vol-ss" {
description = "Xfusion Snapshot"
volume_id = aws_ebs_volume.k8s_volume.id
tags = {
Name = "xfusion-vol-ss"
}
}
output "snapshot_id" {
value = aws_ebs_snapshot.xfusion-vol-ss.id
description = "The ID of snapshot."
}
terraform init
terraform plan -out kke.plan && terraform apply kke.plan
# or apply forcefully without creating plan and applying it
terraform apply -auto-approve