10

I want to restore an RDS instance from a snapshot and have it replace an instance in a cloudformation.

Let's say I have one EC2 instance connected to one RDS instance in a cloud formation and I want to restore the RDS instance from a snapshot.

Since an RDS snapshot can only be restored into a new RDS instance, and that new RDS instance needs the domain name of the old instance for my EC2 to reach it, I have to let go of the old RDS instance by renaming or deleting before creating the new restore, but then the new RDS is not in my cloud formation stack anymore and does not have the proper tags. Instead the tags are in my old throw away instance.

This causes some negative side effects, like problems deleting the cloudformation stack and issues with taking a proper inventory.

Anyone know how to put the new restored instance into my cloudformation again?

Henry Grantham
  • 671
  • 1
  • 6
  • 10
  • you can use cloudformation to restore from a snapshot. If that's an acceptable solution, let me know. If you are asking "how to get a 'foreign' RDS into a cloudformation stack", my answer won't help. – tedder42 Aug 27 '15 at 21:09
  • I AM trying to get a 'foreign RDS into a cloudformation stack' because restoring a snapshot results in a foreign RDS, even though it will hook back up to my EC2 in the original cloud formation with no problem. – Henry Grantham Aug 28 '15 at 17:24

1 Answers1

6

If you support downtime, you can proceed to:

  1. append the 'DBSnapshotIdentifier' to your RDS cloudformation template
  2. update your CFN stack which will recreate your RDS DB from the snapshot.
  3. update your DNS/hosts entries since the new RDS instance will have a new address.
  • 2
    make sure to not specify `DBName` if you are specifying `DBSnapshotIdentifier`. – tedder42 Aug 28 '15 at 19:23
  • you cannot specify a DBInstanceIdentifier either. – Henry Grantham Aug 31 '15 at 20:05
  • This solution partially works, except it does not delete the old rds from the cloudformation, so there is an extra one there and I think that deleting it manually will mess up the way that cloudformation keeps track of the stack. Also step 3 can be avoided by changing the DBInstanceIdentifier back to the old one. – Henry Grantham Aug 31 '15 at 20:13
  • 7
    Be aware that if you want to update the RDS template in the future you'll always have to specify the name of the DBSnapshotIdentifier. If you don't, AWS will consider this a change and will create a new RDS stack, although you just want to update the stack. This is quite annoying and I wonder if CloudFormation is the best way to setup the RDS stack – Markus Rudel Nov 20 '17 at 12:49