Skip to content

Instantly share code, notes, and snippets.

@shimizukawa
Created July 15, 2015 07:59
Show Gist options
  • Save shimizukawa/fc72a91d626a0f9e402f to your computer and use it in GitHub Desktop.
Save shimizukawa/fc72a91d626a0f9e402f to your computer and use it in GitHub Desktop.
RDS instance restore from snapshot / delete instance by using ansible (1.9.1 or later)
[rds]
localhost ansible_python_interpreter=~/.venv/bin/python
---
- name: restore/delete rds instance
hosts: rds
connection: local
gather_facts: true
vars:
instance_name: 'ansibletest'
snapshot: 'mysql-2015-07-13'
tasks:
- name: Restore rds from snapshot
tags: restore
local_action:
module: rds
command: restore
snapshot: '{{ snapshot }}'
instance_name: '{{ instance_name }}'
backup_retention: 0
wait: yes
wait_timeout: 1200
- name: Delete rds instance
tags: delete
local_action:
module: rds
command: delete
instance_name: '{{ instance_name }}'
wait: yes
wait_timeout: 1200
$ ansible-playbook -i rds-hosts rds-manip.yml -t restore
$ ansible-playbook -i rds-hosts rds-manip.yml -t delete
$ ansible-playbook -i rds-hosts rds-manip.yml -t restore --extra-vars "snapshot=mysql-back-20150709"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment