Implementing snapshots on rds instance deletion

This commit is contained in:
Jack Danger Canty 2017-06-20 14:46:13 -07:00
parent 8df7169915
commit e57798cb96
3 changed files with 13 additions and 7 deletions

View File

@ -114,8 +114,7 @@ class RDSResponse(BaseResponse):
def delete_db_instance(self):
db_instance_identifier = self._get_param('DBInstanceIdentifier')
db_snapshot_name = self._get_param('FinalDBSnapshotIdentifier')
database = self.backend.delete_database(db_instance_identifier, db_snapshot_name)
database = self.backend.delete_database(db_instance_identifier)
template = self.response_template(DELETE_DATABASE_TEMPLATE)
return template.render(database=database)

View File

@ -140,7 +140,8 @@ class RDS2Response(BaseResponse):
def delete_db_instance(self):
db_instance_identifier = self._get_param('DBInstanceIdentifier')
database = self.backend.delete_database(db_instance_identifier)
db_snapshot_name = self._get_param('FinalDBSnapshotIdentifier')
database = self.backend.delete_database(db_instance_identifier, db_snapshot_name)
template = self.response_template(DELETE_DATABASE_TEMPLATE)
return template.render(database=database)

View File

@ -145,10 +145,10 @@ def test_delete_database():
conn = boto3.client('rds', region_name='us-west-2')
instances = conn.describe_db_instances()
list(instances['DBInstances']).should.have.length_of(0)
conn.create_db_instance(DBInstanceIdentifier='db-master-1',
conn.create_db_instance(DBInstanceIdentifier='db-primary-1',
AllocatedStorage=10,
DBInstanceClass='postgres',
Engine='db.m1.small',
Engine='postgres',
DBInstanceClass='db.m1.small',
MasterUsername='root',
MasterUserPassword='hunter2',
Port=1234,
@ -156,10 +156,16 @@ def test_delete_database():
instances = conn.describe_db_instances()
list(instances['DBInstances']).should.have.length_of(1)
conn.delete_db_instance(DBInstanceIdentifier="db-master-1")
conn.delete_db_instance(DBInstanceIdentifier="db-primary-1",
FinalDBSnapshotIdentifier='primary-1-snapshot')
instances = conn.describe_db_instances()
list(instances['DBInstances']).should.have.length_of(0)
# Saved the snapshot
snapshots = conn.describe_db_snapshots(DBInstanceIdentifier="db-primary-1").get('DBSnapshots')
snapshots[0].get('Engine').should.equal('postgres')
@mock_rds2
def test_delete_non_existant_database():