amazon-web-servicesterraformterraform-provider-awsaws-ebs

Delete previous snapshots and create new snapshot of EBS volume using Terraform


I need to create a snapshot of EBS volume using Terraform. I also have to consider that if the EBS volume has previously snapshots or not. If the EBS volume contains some previous snapshots then i need to delete them from my Terraform code and create a new snapshot of EBS volume.

I am not sure if deletion of resources is possible through Terraform code. If it is possible, how can i delete the previous snapshots and create new snapshot of EBS volume with Terraform.


Solution

  • No it is not possible. However if the previous snapshots were created by terraform, than running terraform destroy before applying the latest version would do the job. But if those snapshots were created by other means than terraform, deleting them using terraform isn't possible at all.