Search code examples
amazon-web-servicesterraformamazon-rds

Restore AWS Backups to RDS using terraform


I have an AWS Backup plan which do a snapshot every day from a RDS instance, created by terraform. (This AWS Backup plan is not created by terraform).

The point is that I have to restore some of this snapshot without my tfstate lose the state of de whole deployment, because if I restore by hand, a new instance will be created and I would have to change the database endpoint in my application pointing to the new rds instance..

Using the aws_db_instance only allow to restore backups created by the own rds and I haven't found any resource to restore using terraform this snapshot..

Is there any way to restore an AWS backup snapshot without lose my tfstate? Could be the solution create the backups in the own RDS service using terraform?

Thanks in advance.


Solution

  • Sadly, you can't do this. You have to restore by hand, and then manually update your TF code to reflect the changes. This is the same situation when your RDS fail-overs due to failures. TF will not be aware of this, and you have to manually correct the drift.