[cloud][inventory] Get tags for RDS instances. (#23989)

* Get tags for RDS instances.

Boto3 only at this time.

Relates to #11569, #14464.

* Add a check for boto3

* Fix HAS_BOTO3 error
pull/23893/merge
Elijah Lynn 7 years ago committed by Ryan Brown
parent 3324d0a4b0
commit c7ae6b9fd5

@ -623,6 +623,13 @@ class Ec2Inventory(object):
''' Makes an AWS API call to the list of RDS instances in a particular
region '''
if not HAS_BOTO3:
self.fail_with_error("Working with RDS instances requires boto3 - please install boto3 and try again",
"getting RDS instances")
client = ec2_utils.boto3_inventory_conn('client', 'rds', region, **self.credentials)
db_instances = client.describe_db_instances()
try:
conn = self.connect_to_aws(rds, region)
if conn:
@ -630,7 +637,14 @@ class Ec2Inventory(object):
while True:
instances = conn.get_all_dbinstances(marker=marker)
marker = instances.marker
for instance in instances:
for index, instance in enumerate(instances):
# Add tags to instances.
instance.arn = db_instances['DBInstances'][index]['DBInstanceArn']
tags = client.list_tags_for_resource(ResourceName=instance.arn)['TagList']
instance.tags = {}
for tag in tags:
instance.tags[tag['Key']] = tag['Value']
self.add_rds_instance(instance, region)
if not marker:
break

Loading…
Cancel
Save