Created
December 11, 2022 23:07
-
-
Save davila7/f4da067d3b3449f5910c133f77b52fa4 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
| #rds | |
| rds = boto3.client('rds', region_name='us-east-1') | |
| # Obtenemos una lista de todas las instancias RDS | |
| rds_instances = rds.describe_db_instances() | |
| stopRdsInstances = [] | |
| #recorremos las instancias y filtramos por tag | |
| for rds_instance in rds_instances["DBInstances"]: | |
| tags = rds.list_tags_for_resource(ResourceName=rds_instance["DBInstanceArn"]) | |
| for tag in tags["TagList"]: | |
| if tag['Key'] == 'Env': | |
| if tag['Value'] == tag_name: | |
| rds.stop_db_instance(DBInstanceIdentifier=rds_instance["DBInstanceIdentifier"]) | |
| print('RDS Apagada: '+str(rds_instance["DBInstanceIdentifier"])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment