Created
September 9, 2019 14:32
-
-
Save saswata-dutta/a758ceb9b81cf3bcc857e91f8583eeff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import boto3 | |
| rds = boto3.client('rds', region_name='ap-south-1') | |
| dbs = rds.describe_db_instances() | |
| def get_tags_for_db(db): | |
| instance_arn = db['DBInstanceArn'] | |
| instance_tags = rds.list_tags_for_resource(ResourceName=instance_arn) | |
| return instance_tags['TagList'] | |
| for db in dbs['DBInstances']: | |
| db_tags = get_tags_for_db(db) | |
| for tag in db_tags: | |
| if tag['Key'] == 'Business_Vertical' and (tag['Value']).lower() == 'ds': | |
| print(db["DBInstanceIdentifier"], ",", db["DBInstanceClass"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment