/aws-rollback

AWS CLI script that rolls back the EC2 instances to previous snapshot.

Primary LanguageShellMIT LicenseMIT

aws-rollback

AWS CLI script that rolls back the EC2 instances to previous snapshot.

Idea

The idea behind the script is to use it to rollback multiple AWS EC2 instances to specified snapshot. If you have some AWS environment that you need to rollback to previous state, this can help you achieve the task. You need to specify the list of instances and their snapshots to which they will be rolled back.

Pre requirements

  1. Install aws-cli on your server that will be the controller of instances.
  2. Create an API access key by following this: https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html
  3. In order to use the script you first need to have setup AWS credentials for user that will use aws-cli. Follow the link https://docs.aws.amazon.com/cli/latest/reference/configure/ to configure the aws tool.

Usage

./aws-rollback.sh <server_list_file> <region_id> <availability_zone> [timeout]

Example

./aws-rollback.sh servers.txt sa-east-1 sa-east-1a

This will run the rollback of all instances in the servers.txt file located in the sa-east-1 zone.

Running automatically?

The script can be scheduled via cronjob for example in some time in the evening, and will run until all instances are rolled back to the snapshots specified.