in lambda/snapshots_tool_utils.py [0:0]
def filter_instances(taggedinstance, pattern, instance_list):
# Takes the response from describe-db-instances and filters according to pattern in DBInstanceIdentifier
filtered_list = []
for instance in instance_list['DBInstances']:
if taggedinstance == 'TRUE':
client = boto3.client('rds', region_name=_REGION)
response = client.list_tags_for_resource(ResourceName=instance['DBInstanceArn'])
if pattern == 'ALL_INSTANCES' and instance['Engine'] in _SUPPORTED_ENGINES:
if (taggedinstance == 'TRUE' and search_tag_copydbsnapshot(response)) or taggedinstance == 'FALSE':
filtered_list.append(instance)
else:
match = re.search(pattern, instance['DBInstanceIdentifier'])
if match and instance['Engine'] in _SUPPORTED_ENGINES:
if (taggedinstance == 'TRUE' and search_tag_copydbsnapshot(response)) or taggedinstance == 'FALSE':
filtered_list.append(instance)
return filtered_list