Skip to content

Instantly share code, notes, and snippets.

@davila7
Created December 11, 2022 23:07
Show Gist options
  • Select an option

  • Save davila7/f4da067d3b3449f5910c133f77b52fa4 to your computer and use it in GitHub Desktop.

Select an option

Save davila7/f4da067d3b3449f5910c133f77b52fa4 to your computer and use it in GitHub Desktop.
#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