Reputation: 163
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.
Upvotes: 6
Views: 6428
Reputation: 69
We handled this situation in the following way in AWS to avoid changing any TF configuration:
db-new
, ensuring that the configuration matches the original dbdb-old
. Note that this will cause your endpoint to change, so your app will lose connectivity when AWS completes the modification.db-new
to have the original db identifier. This will change the endpoint to match the original endpoint.terraform plan
and see whether there are any configuration changes. Make sure to update the new db to match the config in the current TF state.You should see that TF only updates a security group in place, and it sees the new db as matching the old db.
Upvotes: 5
Reputation: 238957
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.
Upvotes: 6