How to restore via AWS Backup within Terraform

I manage all my AWS resources through Terraform.
AWS Backup vaults for EC2, EFS, RDS, etc. backups are also created through terraform.
However, there is a problem in recovering through terraform with the created backup vault.
Is there no way to use terraform to restore a vault created through AWS Backup?

Hi @jhlee857,

Restoring from a backup is a one-time imperative operation and so not really a good fit for Terraform’s declarative model.

With a suitable provider design is is possible in principle to describe restoring a backup, but that then raises the question of what should happen once the backup has already been restored and so the configuration ought not to go on referring to the old snapshot forever.

Instead, folks typically handle this sort of exceptional situation by using the AWS CLI to request the restore and then import the resulting object into Terraform so that it can be managed there in the future.

This is a pragmatic answer for an action that is hopefully taken relatively infrequently. (Though be sure to rehearse it in a non-production environment so you know that your restore procedure will actually work!)

1 Like