下面是我使用python boto3从rds快照恢复rds实例的代码
import boto3
x=input('Please enter the RDS Instance Name :')
z=input('Please enter the RDS Snapshot Name :')
y=input('Please enter the RDS Instance Class:')
a=input('Please enter the RDS Instance Subnet Group Name:')
client = boto3.client('rds', region_name='xxxxxxx')
rdsinstances = client.restore_db_instance_from_db_snapshot(DBInstanceIdentifier=x.strip(),DBSnapshotIdentifier=z.strip(),DBInstanceClass=y.strip(),DBSubnetGroupName=a.strip())
for i in rdsinstances['DBInstance']:
print('Instance_name:' + i['DBInstanceIdentifier'])
print('DB_Instance_Status:' + i['DBInstanceStatus'])
print('DB_Instance_Class:' + i['DBInstanceClass'])
print('DB_Subnet_Group:' + i['DBSubnetGroupName'])
我的代码能够从RDS快照恢复db实例,但第10行的打印输出失败。
"TypeError: string indices must be integers".
请任何人告诉我,在调用“restore_db_instance_from_db_snapshot”模块的键和值时,我哪里做错了。