import json
import boto3
import pprint
def lambda_handler(event, context):
# TODO implement
rds = boto3.client('rds')
old = {'DBInstanceClass': 'db.t2.micro',
'DBInstanceIdentifier': 'backuptest-mysql-snapshot',
'DBInstanceStatus': 'available',
'DBSubnetGroupName': '',
'Endpoint': {'Address': '',
'HostedZoneId': '',
'Port': 3306},
'Engine': 'mysql',
'LicenseModel': 'general-public-license'}
old = {'DBInstanceClass': 'db.t2.micro',
'DBInstanceIdentifier': 'backupteste-pgsql-snapshot',
'DBInstanceStatus': 'available',
'DBSubnetGroupName': '',
'Endpoint': {'Address': '',
'HostedZoneId': '',
'Port': 5432},
'Engine': 'postgres',
'LicenseModel': 'postgresql-license'}
newinstance = rds.restore_db_instance_from_db_snapshot(
DBInstanceIdentifier=old["DBInstanceIdentifier"]+"-fromsnapshot",
DBSnapshotIdentifier=old["DBInstanceIdentifier"],
DBInstanceClass=old["DBInstanceClass"],
Port=old["Endpoint"]["Port"],
DBSubnetGroupName=old["DBSubnetGroupName"],
MultiAZ=False,
PubliclyAccessible=False,
LicenseModel=old["LicenseModel"],
AutoMinorVersionUpgrade=False,
#OptionGroupName=
#Tags
)
pprint.pprint(newinstance)
return "ok"