下對我的作品(假設一個RDS實例,但你可以改變):
def get_db_info():
rds_conn = boto.connect_rds2(profile_name=AWS_PROFILE)
if not rds_conn:
print(_red('Cannot connect to AWS.RDS'))
return
instances = rds_conn.describe_db_instances()
if not instances:
print(_red('No instances found'))
return
inst = instances['DescribeDBInstancesResponse']['DescribeDBInstancesResult']['DBInstances'][0]
dbinfo = {}
endpoint = inst['Endpoint']
dbinfo['VPCSecurityGroupId'] = inst['VpcSecurityGroups'][0]['VpcSecurityGroupId']
dbinfo['dbSecurityGroupName'] = inst['DBSecurityGroups'][0]['DBSecurityGroupName']
print('')
print(_blue('db Info ===========>\n'))
for item in dbinfo:
print(_green('%20s : %s' % (item, dbinfo[item])))
取而代之的是PROFILE_NAME的,您可以使用AWS密鑰/祕密參數
你能發佈您正在使用的代碼以及您從RDS獲得的響應? – garnaat 2015-04-02 13:06:46
完成...對不起fr晚回覆:) – 2015-04-04 10:42:06
你使用VPC嗎?如果是這樣,你會發現具有屬性「vpc_security_groups」屬性而不是「security_groups」屬性的安全組。 – garnaat 2015-04-07 00:19:04