PK!J |PPrightsizer/AwsRightSizer.py# Standard Library Imports from datetime import ( datetime, timedelta, ) # Third-Party Imports import boto3 from botocore.exceptions import ClientError # Local Imports from . import logger class Main: def __init__( self, thresholdAvg, thresholdMax, queryDays, queryPeriod, output, accessKey=None, secretKey=None, region=None, profile=None, ): self.accessKey = accessKey self.secretKey = secretKey self.region = region self.profile = profile self.threasholdAvg = thresholdAvg self.threasholdMax = thresholdMax self.queryDays = queryDays self.queryPeriod = queryPeriod self.output = output def _serialize_datetime(self, t): """ A method to serialize AWS datetime objects to be displayed as JSON (future use) :param t: :return: (string) the datetime object as a str object """ if isinstance(t, datetime): return t.__str__() def _init_connection(self, service): """ A method to initialize an AWS service connection with access/secret access keys. :param service: :return: (object) the AWS connection object. """ try: s = boto3.Session( aws_access_key_id='{}'.format(self.accessKey), aws_secret_access_key='{}'.format(self.secretKey), region_name='{}'.format(self.region), ) c = s.client('{}'.format(service)) return c except ClientError as e: logger.error('Error Connecting with the provided credentials. {}'.format(e)) return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] def _init_profile(self, service): """ A method to initialize an AWS service connection with an AWS profile. :param service: :return: (object) the AWS connection object. """ try: s = boto3.Session( profile_name='{}'.format(self.profile) ) c = s.client('{}'.format(service)) return c except ClientError as e: logger.error('Error Connecting with the provided credentials... {}'.format(e)) return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] def getec2suggestions(self): """ A method to suggest the right sizing for AWS EC2 Instances. :return: (dictionary) The dictionary result of the logic. """ if self.accessKey is not None: cwc = self.initconnection('cloudwatch') ec2c = self.initconnection('ec2') else: cwc = self.initprofile('cloudwatch') ec2c = self.initprofile('ec2') try: response = ec2c.describe_instances() except ClientError as e: logger.error('Failed to describe instances... {}'.format(e)) return [] except Exception as e: logger.exception('General Exception... {}'.format(e)) return [] now = datetime.now() sTime = now - timedelta(days=self.queryDays) eTime = now.strftime("%Y-%m-%d %H:%M:%S") info = [] for a in range(0, len(response['Reservations'])): for b in range(0, len(response['Reservations'][a]['Instances'])): base = response['Reservations'][a]['Instances'][b] try: instanceState = base['State']['Name'] except KeyError: logger.exception('Instance State Undefined') return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] try: instanceId = base['InstanceId'] except KeyError: logger.exception('Instance Id Undefined') return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] try: instanceType = base['InstanceType'] except KeyError: logger.exception('Instance Type Undefined') return [] except Exception as e: logger.exception('Gerneral Exception ... {}'.format(e)) return [] if instanceState != 'terminated': try: for c in range(0, len(base['Tags'])): if base['Tags'][c]['Key'] == 'Name': instanceName = base['Tags'][c]['Value'] except KeyError: logger.info("Instance Name Undefined, Setting to 'Undefined'") instanceName = 'Undefined' try: res = cwc.get_metric_statistics( Namespace='AWS/EC2', MetricName='CPUUtilization', Dimensions=[ { 'Name': 'InstanceId', 'Value': '{}'.format(instanceId) } ], StartTime=sTime, EndTime=eTime, Period=self.queryPeriod, Statistics=[ 'Average', ], Unit='Percent' ) for x in range(0, len(res['Datapoints'])): metrics = [] cwbase = res['Datapoints'][x] Average = cwbase['Average'] metrics.append(Average) totalAvg = round((sum(metrics)/len(metrics)), 2) # General Purpose Instance Types t1types = [ 'micro', ] t2types = [ 'nano', 'micro', 'small', 'medium', 'large', 'xlarge', '2xlarge', ] m1types = [ 'small', 'medium', 'large', 'xlarge', ] m3types = [ 'medium', 'large', 'xlarge', '2xlarge', ] m4types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '10xlarge', '16xlarge', ] m5types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '12xlarge', '24xlarge', ] m5dtypes = [ 'large', 'xlarge', '2xlarge', '4xlarge', '12xlarge', '24xlarge', ] # Compute Optimized Instance Types c1types = [ 'medium', 'xlarge', ] cc2types = [ '8xlarge', ] c3types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', ] c4types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', ] c5types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '9xlarge', '18xlarge', ] c5dtypes = [ 'large', 'xlarge', '2xlarge', '4xlarge', '9xlarge', '18xlarge', ] # Memory Optimized Instance Types cr1types = [ '8xlarge', ] m2types = [ 'xlarge', '2xlarge', '4xlarge', ] r3types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', ] r4types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge', ] r5types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '12xlarge', '24xlarge', ] r5dtypes = [ 'large', 'xlarge', '2xlarge', '4xlarge', '12xlarge', '24xlarge', ] x1types = [ '16xlarge', '32xlarge' ] x1etypes = [ 'xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge', '32xlarge', ] z1dtypes = [ 'large', 'xlarge', '2xlarge', '3xlarge', '6xlarge', '12xlarge', ] # GPU/Accelerated Compute Optimized Instance Types g2types = [ '2xlarge', '8xlarge', ] g3types = [ '4xlarge', '8xlarge', '16xlarge', ] p2types = [ 'xlarge', '8xlarge', '16xlarge', ] p3types = [ '2xlarge', '8xlarge', '16xlarge', ] f1types = [ '2xlarge', '16xlarge', ] # Storage Optimized Instance Types i2types = [ 'xlarge', '2xlarge', '4xlarge', '8xlarge', ] i3types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge', 'metal', ] h1types = [ '2xlarge', '4xlarge', '8xlarge', '16xlarge', ] hs1types = [ '8xlarge', ] d2types = [ 'xlarge', '2xlarge', '4xlarge', '8xlarge', ] typesplit = instanceType.split('.') # If instance is already t2.nano, keep it the same if instanceType == 't2.nano': suggestedType = 't2.{}'.format(t2types[0]) # Suggest Instance Types based on AVG CPU usage keeping general instance type class, current gen only if typesplit[0] == 't1': suggestedType = 't2.{}'.format(t2types[0]) elif typesplit[0] == 't2': typeindex = t2types.index('{}'.format(typesplit[1])) if totalAvg <=5: suggestedType = '{}.{}'.format(typesplit[0], t2types[0]) elif totalAvg > 5 <= 30: index = typeindex -1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], t2types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], t2types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], t2types[index]) except IndexError: suggestedType = 'm4.{}'.format(m4types[3]) elif typesplit[0] == 'm5': typeindex = m5types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], m5types[0]) elif totalAvg > 5 <= 30: index = typeindex -1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], m5types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], m5types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], m5types[index]) except IndexError: suggestedType = 'm5.{}'.format(m5types[5]) elif typesplit[0] == 'm5d': typeindex = m5dtypes.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], m5dtypes[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], m5dtypes[0]) else: suggestedType = '{}.{}'.format(typesplit[0], m5dtypes[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], m5dtypes[index]) except IndexError: suggestedType = 'm5d.{}'.format(m5dtypes[5]) elif typesplit[0] == 'm4': typeindex = m4types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], m4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], m4types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], m4types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], m4types[index]) except IndexError: suggestedType = 'm5.{}'.format(m5types[5]) elif typesplit[0] == 'm3': # PrevGen Upgrade to M5 typeindex = m3types.index(typesplit[1]) if totalAvg <= 5: suggestedType = 't2.{}*'.format(t2types[2]) elif totalAvg > 5 <= 30: index = typeindex - 2 if index < 0: suggestedType = 't2.{}*'.format(t2types[3]) else: suggestedType = 'm5.{}*'.format(m5types[index]) elif totalAvg > 30 <= 80: index = typeindex - 1 if index < 0: suggestedType = 'm5.{}*'.format(m5types[2]) else: suggestedType = 'm5.{}*'.format(m5types[index]) elif totalAvg > 80: try: suggestedType = 'm5.{}*'.format(m5types[typeindex]) except IndexError: suggestedType = 'm5.{}*'.format(m5types[2]) elif typesplit[0] == 'm2': # PrevGen Upgrade to R4 typeindex = m2types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'r4.{}*'.format(r4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 'r4.{}*'.format(r4types[0]) else: suggestedType = 'r4.{}*'.format(r4types[index]) elif totalAvg > 30 <= 80: index = typeindex + 1 suggestedType = 'r4.{}*'.format(r4types[index]) elif totalAvg > 80: index = typeindex + 2 try: suggestedType = 'r4.{}*'.format(r4types[index]) except IndexError: suggestedType = 'r4.{}*'.format(r4types[5]) elif typesplit[0] == 'm1': # PrevGen Upgrade to T2 typeindex = m1types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 't2.{}*'.format(t2types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 't2.{}*'.format(t2types[0]) else: suggestedType = 't2.{}*'.format(t2types[index]) elif totalAvg > 30 <= 80: suggestedType = 't2.{}*'.format(t2types[typeindex]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = 't2.{}*'.format(t2types[index]) except IndexError: suggestedType = 'm4.{}*'.format(m4types[3]) elif typesplit[0] == 'c5': typeindex = c5types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], c5types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], c5types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], c5types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], c5types[index]) except IndexError: suggestedType = 'c5.{}'.format(c5types[5]) elif typesplit[0] == 'c5d': typeindex = c5dtypes.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], c5dtypes[0]) elif totalAvg > 5 <= 30: index = typeindex -1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], c5dtypes[0]) else: suggestedType = '{}.{}'.format(typesplit[0], c5dtypes[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], c5dtypes[index]) except IndexError: suggestedType = 'c5d.{}'.format(c5dtypes[5]) elif typesplit[0] == 'c4': typeindex = c4types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], c4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], c4types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], c4types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], c4types[index]) except IndexError: suggestedType = 'c5.{}'.format(c5types[5]) elif typesplit[0] == 'c3': # PrevGen Upgrade to C5 typeindex = c3types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'c5.{}*'.format(c5types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 'c5.{}*'.format(c5types[0]) else: suggestedType = 'c5.{}*'.format(c5types[index]) elif totalAvg > 30 <= 80: suggestedType = 'c5.{}*'.format(c5types[typeindex]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = 'c5.{}*'.format(c5types[index]) except IndexError: suggestedType = 'c5.{}*'.format(c5types[5]) elif typesplit[0] == 'cc2': # PrevGen Upgrade to C5 typeindex = cc2types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'c5.{}*'.format(c5types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 'c5.{}*'.format(c5types[3]) else: suggestedType = 'c5.{}*'.format(c5types[index]) elif totalAvg > 30 <= 80: suggestedType = 'c5.{}*'.format(c5types[4]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = 'c5.{}*'.format(c5types[index]) except IndexError: suggestedType = 'c5.{}*'.format(c5types[5]) elif typesplit[0] == 'cr1': # PrevGen Upgrade to R4 typeindex = m2types.index('{}'.format(typesplit[1])) if totalAvg <= 30: suggestedType = 'r4.{}'.format(r4types[0]) elif totalAvg > 30 <= 80: suggestedType = 'r4.{}'.format(r4types[4]) elif totalAvg > 80: suggestedType = 'r4.{}'.format(r4types[5]) elif typesplit[0] == 'c1': # PrevGen Upgrade to C5 typeindex = c1types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'c5.{}*'.format(c5types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 'c5.{}*'.format(c5types[0]) else: suggestedType = 'c5.{}*'.format(c5types[index]) elif totalAvg > 30 <= 80: suggestedType = 'c5.{}*'.format(c5types[typeindex]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = 'c5.{}*'.format(c5types[index]) except IndexError: suggestedType = 'c5.{}*'.format(c5types[5]) elif typesplit[0] == 'x1': typeindex = x1types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], x1types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], x1types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], x1types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], x1types[index]) except IndexError: suggestedType = 'x1e.{}'.format(x1etypes[5]) elif typesplit[0] == 'x1e': typeindex = x1etypes.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], x1etypes[0]) elif totalAvg > 5 <= 30: index = typeindex -1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], x1etypes[0]) else: suggestedType = '{}.{}'.format(typesplit[0], x1etypes[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], x1etypes[index]) except IndexError: suggestedType = 'x1e.{}'.format(x1etypes[5]) elif typesplit[0] == 'z1d': typeindex = z1dtypes.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], z1dtypes[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], z1dtypes[0]) else: suggestedType = '{}.{}'.format(typesplit[0], z1dtypes[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], z1dtypes[index]) except IndexError: suggestedType = 'x1.{}'.format(x1types[0]) elif typesplit[0] == 'r5d': typeindex = r5dtypes.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], r5dtypes[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], r5dtypes[0]) else: suggestedType = '{}.{}'.format(typesplit[0], r5dtypes[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], r5dtypes[index]) except IndexError: suggestedType = 'x1.{}'.format(x1types[0]) elif typesplit[0] == 'r5': typeindex = r5types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], r5types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], r5types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], r5types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], r5types[index]) except IndexError: suggestedType = 'x1.{}'.format(x1types[0]) elif typesplit[0] == 'r4': typeindex = r4types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], r4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], r4types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], r4types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], r4types[index]) except IndexError: suggestedType = 'r5.{}'.format(r5types[5]) elif typesplit[0] == 'r3': # PrevGen Upgrade to R4 typeindex = r3types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'r4.{}*'.format(r4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 'r4.{}*'.format(r4types[0]) else: suggestedType = 'r4.{}*'.format(r4types[index]) elif totalAvg > 30 <= 80: suggestedType = 'r4.{}*'.format(r4types[typeindex]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = 'r4.{}*'.format(r4types[index]) except IndexError: suggestedType = 'x1.{}*'.format(x1types[0]) elif typesplit[0] == 'p2': typeindex = p2types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], p2types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], p2types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], p2types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], p2types[index]) except IndexError: suggestedType = 'g3.{}'.format(g3types[0]) elif typesplit[0] == 'p3': typeindex = p3types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], p3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], p3types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], p3types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], p3types[index]) except IndexError: suggestedType = 'g3.{}'.format(g3types[0]) elif typesplit[0] == 'g3': typeindex = g3types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], g3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], g3types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], g3types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], g3types[index]) except IndexError: suggestedType = 'f1.{}'.format(f1types[1]) elif typesplit[0] == 'g2': # PrevGen Upgrade to G3 typeindex = g2types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'g3.{}*'.format(g3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = 'g3.{}*'.format(g3types[0]) else: suggestedType = 'g3.{}*'.format(g3types[index]) elif totalAvg > 30 <= 80: suggestedType = 'g3.{}*'.format(typeindex) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = 'g3.{}*'.format(g3types[index]) except IndexError: suggestedType = 'f1.{}*'.format(f1types[1]) elif typesplit[0] == 'f1': typeindex = f1types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], f1types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], f1types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], f1types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], f1types[index]) except IndexError: suggestedType = 'f1.{}'.format(f1types[1]) elif typesplit[0] == 'hs1': # PrevGen Upgrade to d2 typeindex = hs1types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'd2.{}*'.format(d2types[0]) elif totalAvg > 5 <= 30: suggestedType = 'd2.{}*'.format(d2types[1]) elif totalAvg > 30: suggestedType = 'd2.{}*'.format(d2types[3]) elif typesplit[0] == 'h1': typeindex = h1types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], h1types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], h1types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], h1types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], h1types[index]) except IndexError: suggestedType = 'i3.{}'.format(i3types[6]) elif typesplit[0] == 'i3': typeindex = i3types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], i3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], i3types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], i3types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], i3types[index]) except IndexError: suggestedType = 'i3.{}'.format(i3types[6]) elif typesplit[0] == 'i2': # PrevGen Upgread to i3 typeindex = i2types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = 'i3.{}*'.format(i3types[0]) elif totalAvg > 5 <= 30: try: suggestedType = 'i3.{}*'.format(i3types[typeindex]) except ValueError: suggestedType = 'i3.{}*'.format(i3types[0]) elif totalAvg > 30 <= 80: suggestedType = 'i3.{}*'.format(i3types[typeindex]) elif totalAvg > 80: try: index = typeindex + 2 suggestedType = 'i3.{}*'.format(i3types[index]) except IndexError: suggestedType = 'i3.{}*'.format(i3types[6]) elif typesplit[0] == 'd2': typeindex = d2types.index('{}'.format(typesplit[1])) if totalAvg <= 5: suggestedType = '{}.{}'.format(typesplit[0], d2types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}'.format(typesplit[0], d2types[0]) else: suggestedType = '{}.{}'.format(typesplit[0], d2types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(instanceType) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}'.format(typesplit[0], d2types[index]) except IndexError: suggestedType = 'd2.{}'.format(d2types[3]) except ClientError as e: logger.error('Error getting metrics for instance {}...{}'.format(b, e)) except Exception as e: logger.exception('General Exception ... {}'.format(e)) info.append( { 'Id': '{}'.format(instanceId), 'Name': '{}'.format(instanceName), 'AvgCpu': totalAvg, 'CurrentType': '{}'.format(instanceType), 'SuggestedType': '{}'.format(suggestedType) } ) return info def getrdssuggestions(self): """ A method to suggest the right sizing for AWS RDS Instances. :return: (dictionary) The dictionary result of the logic. """ if self.accessKey is not None: cwc = self.initconnection('cloudwatch') rdsc = self.initconnection('rds') else: cwc = self.initprofile('cloudwatch') rdsc = self.initprofile('rds') try: response = rdsc.describe_db_instances() except ClientError as e: logger.error('Failed to describe rds instances... {}'.format(e)) return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] now = datetime.now() sTime = now - timedelta(days=self.queryDays) eTime = now.strftime("%Y-%m-%d %H:%M:%S") info = [] for a in range(0, len(response['DBInstances'])): base = response['DBInstances'][a] try: DBInstanceStatus = base['DBInstanceStatus'] except KeyError: logger.exception('RDS Instance Statue Undefined') return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] try: DBInstanceIdentifier = base['DBInstanceIdentifier'] except KeyError: logger.exception('RDS Instance Id Undefined') return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] try: DBInstanceClass = base['DBInstanceClass'] except KeyError: logger.exception('RDS Instance Class Undefined') return [] except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] try: DBEngine = base['Engine'] except KeyError: logger.error('RDS DB Engine Undefined') DBEngine = 'Undefined' except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] try: DBName = base['DBName'] except KeyError: logger.info("RDS DB Name Undefined, setting to 'Undefined'") DBName = 'Undefined' except Exception as e: logger.exception('General Exception ... {}'.format(e)) return [] if DBInstanceStatus == 'available': try: res = cwc.get_metric_statistics( Namespace='AWS/RDS', MetricName='CPUUtilization', Dimensions=[ { 'Name': 'DBInstanceIdentifier', 'Value': '{}'.format(DBInstanceIdentifier) } ], StartTime=sTime, EndTime=eTime, Period=self.queryPeriod, Statistics=[ 'Average', ], Unit='Percent' ) for x in range(0, len(res['Datapoints'])): metrics = [] cwbase = res['Datapoints'][x] Average = cwbase['Average'] metrics.append(Average) totalAvg = round((sum(metrics)/len(metrics)), 2) # General Purpose DB Instance Types dbm4types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '10xlarge', '16xlarge', ] dbm3types = [ 'medium', 'large', 'xlarge', '2xlarge', ] dbm1types = [ 'small', 'medium', 'large', 'xlarge', ] # Memory Optimized DB Instance Types dbm2types = [ 'xlarge', '2xlarge', '4xlarge', ] dbr4types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge', ] dbr3types = [ 'large', 'xlarge', '2xlarge', '4xlarge', '8xlarge', ] dbx1etypes = [ 'xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge', '32xlarge', ] dbx1types = [ '16xlarge', '32xlarge', ] # Burstable DB Instance Types dbt1types = [ 'micro' ] dbt2types = [ 'micro', 'small', 'medium', 'large', 'xlarge', '2xlarge', ] typesplit = DBInstanceClass.split('.') # Suggest Instance Types based on AVG CPU usage keeping general instance type class if typesplit[1] == 't2': typeindex = dbt2types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbt2types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbt2types[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbt2types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbt2types[index]) except IndexError: suggestedType = '{}.m4.{}'.format(typesplit[0], dbm4types[3]) elif typesplit[1] == 't1': # PrevGen Upgrade to t2 suggestedType = '{}.t2.{}*'.format(typesplit[0], dbt2types[0]) elif typesplit[1] == 'm4': typeindex = dbm4types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm4types[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm4types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm4types[index]) except IndexError: suggestedType = '{}.x1e.{}'.format(typesplit[0], dbx1etypes[4]) elif typesplit[1] == 'm3': typeindex = dbm3types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm3types[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm3types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbm3types[index]) except IndexError: suggestedType = '{}.m4.{}'.format(typesplit[0], dbm4types[3]) elif typesplit[1] == 'm2': # PrevGen Upgrade to R3 typeindex = dbm2types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.r3.{}'.format(typesplit[0], dbr3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.r3.{}'.format(typesplit[0], dbr3types[0]) else: suggestedType = '{}.r3.{}'.format(typesplit[0], dbr3types[index]) elif totalAvg > 30 <= 80: index = typeindex suggestedType = '{}.r3.{}'.format(typesplit[0], dbr3types[index]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.r3.{}'.format(typesplit[0], dbr3types[index]) except IndexError: suggestedType = '{}.r3.{}'.format(typesplit[0], dbr3types[4]) elif typesplit[1] == 'm1': # PrevGen Upgrade to t2 typeindex = dbm1types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.t2.{}'.format(typesplit[0], dbt2types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.t2.{}'.format(typesplit[0], dbt2types[0]) else: suggestedType = '{}.t2.{}'.format(typesplit[0], dbt2types[index]) elif totalAvg > 30 <= 80: index = typeindex + 1 suggestedType = '{}.t2.{}'.format(typesplit[0], dbt2types[index]) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.t2.{}'.format(typesplit[0], dbt2types[index]) except IndexError: suggestedType = '{}.t2.{}'.format(typesplit[0], dbt2types[3]) elif typesplit[1] == 'r4': typeindex = dbr4types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr4types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr4types[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr4types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr4types[index]) except IndexError: suggestedType = '{}.x1e.{}'.format(typesplit[0], dbx1etypes[4]) elif typesplit[1] == 'r3': typeindex = dbr3types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr3types[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr3types[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr3types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbr3types[index]) except IndexError: suggestedType = '{}.r4.{}'.format(typesplit[0], dbr4types[5]) elif typesplit[1] == 'x1e': typeindex = dbx1etypes.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1etypes[0]) elif totalAvg > 5 <= 30: index = typeindex - 1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1etypes[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1etypes[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1etypes[index]) except IndexError: suggestedType = '{}.x1e.{}'.format(typesplit[0], dbx1etypes[5]) elif typesplit[1] == 'x1': typeindex = dbx1types.index('{}'.format(typesplit[2])) if totalAvg <= 5: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1types[0]) elif totalAvg > 5 <= 30: index = typeindex -1 if index < 0: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1types[0]) else: suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1types[index]) elif totalAvg > 30 <= 80: suggestedType = '{}'.format(DBInstanceClass) elif totalAvg > 80: try: index = typeindex + 1 suggestedType = '{}.{}.{}'.format(typesplit[0], typesplit[1], dbx1types[index]) except IndexError: suggestedType = '{}.x1e.{}'.format(typesplit[0], dbx1etypes[5]) except ClientError as e: logger.error('Error getting metrics for instance {}...{}'.format(a, e)) except Exception as e: logger.exception('General Exception ... {}'.format(e)) info.append( { 'Id': '{}'.format(DBInstanceIdentifier), 'Name': '{}'.format(DBName), 'Engine': '{}'.format(DBEngine), 'AvgCpu': totalAvg, 'CurrentType': '{}'.format(DBInstanceClass), 'SuggestedType': '{}'.format(suggestedType) } ) return info PK!rightsizer/__init__.pyimport logging logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) logging.getLogger('boto3').setLevel(logging.WARNING) logging.getLogger('botocore').setLevel(logging.WARNING)PK!g/p@@rightsizer/main.py# Standard Library Imports import csv import argparse from datetime import datetime # Third-party Imports # Local Imports from . import logger from .AwsRightSizer import Main def main(): """ The primary method that provides two CSV output files (EC2/RDS) with suggestions. :return: (none): This method does not return anything, it only creates the two CSV file objects. """ parser = argparse.ArgumentParser() parser.add_argument( '-p', '--profile', dest='profile', help='AWS Credentials Profile', default='default', required=False ) parser.add_argument( '-k', '--access-key', dest='accessKey', help='AWS Access Key Id', default=None, required=False ) parser.add_argument( '-s', '--secret-key', dest='secretKey', help='AWS Secret Access Key', default=None, required=False ) parser.add_argument( '-r', '--region', dest='region', help='AWS Region', default=None, required=False ) parser.add_argument( '-t', '--threshold', nargs=2, dest='threshold', help='The Cloudwatch [average, max] CPU usage threshold', default=[5, 30], required=False ) parser.add_argument( '-q', '--query-config', dest='query', help='The amount of [days, period] to query Cloudwatch for', default=[30, 1800], required=False ) parser.add_argument( '-o', '--output', dest='output', help='The name/location of the csv file to output', default='report_{}.csv'.format(datetime.date(datetime.now())) ) parser.add_argument( '-e', '--ec2-only', action='store_true', dest='ec2only', help='Run this tool against EC2 Instances only', ) parser.add_argument( '-d', '--rds-only', action='store_true', dest='rdsonly', help='Run this tool against RDS Instances only', ) args = parser.parse_args() x = Main( accessKey=args.accessKey, secretKey=args.secretKey, region=args.region, profile=args.profile, thresholdAvg=args.threshold[0], thresholdMax=args.threshold[1], queryDays=args.query[0], queryPeriod=args.query[1], output=args.output ) if args.ec2only: if args.profile: pf = args.profile else: pf = args.region extra = { 'Id': '* - AWS Suggested Upgrade' } with open('{}_ec2_'+'{}'.format(pf, x.output), 'w', newline='') as f: fieldnames = [ 'Id', 'Name', 'AvgCpu', 'CurrentType', 'SuggestedType' ] w = csv.DictWriter(f, fieldnames) w.writeheader() for r in x.getec2suggestions(): w.writerow(r) csv.writer(f).writerow('') w.writerow(extra) elif args.rdsonly: if args.profile: pf = args.profile else: pf = args.region extra = { 'Id': '* - AWS Suggested Upgrade' } with open('{}_rds_'+'{}'.format(pf, x.output), 'w', newline='') as f: fieldnames = [ 'Id', 'Name', 'Engine', 'AvgCpu', 'CurrentType', 'SuggestedType' ] w = csv.DictWriter(f, fieldnames) w.writeheader() for r in x.getrdssuggestions(): w.writerow(r) csv.writer(f).writerow('') w.writerow(extra) else: if args.profile: pf = args.profile else: pf = args.region extra = { 'Id': '* - AWS Suggested Upgrade' } with open('{}_ec2_' + '{}'.format(pf, x.output), 'w', newline='') as f: fieldnames = [ 'Id', 'Name', 'AvgCpu', 'CurrentType', 'SuggestedType' ] w = csv.DictWriter(f, fieldnames) w.writeheader() for r in x.getec2suggestions(): w.writerow(r) csv.writer(f).writerow('') w.writerow(extra) with open('{}_rds_' + '{}'.format(pf, x.output), 'w', newline='') as f: fieldnames = [ 'Id', 'Name', 'Engine', 'AvgCpu', 'CurrentType', 'SuggestedType' ] w = csv.DictWriter(f, fieldnames) w.writeheader() for r in x.getrdssuggestions(): w.writerow(r) csv.writer(f).writerow('') w.writerow(extra)PK!HO*30awsrightsizer-1.0.7.2.dist-info/entry_points.txtN+I/N.,()*L()άJ-E0r3@PK!l.P,P,'awsrightsizer-1.0.7.2.dist-info/LICENSE Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2018 Jordan Gregory Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. PK!HW"TT%awsrightsizer-1.0.7.2.dist-info/WHEEL A н#J."jm)Afb~ ڡ5 G7hiޅF4+-3ڦ/̖?XPK!HV(awsrightsizer-1.0.7.2.dist-info/METADATAXn8Sfrh:nmf&k'31-6ITIʮŢ>Xd:XNG@N$‰X! w!+k|4۰?{l\f0Ր-tϝ)~BtT.[HkcdʭyŪJ+L1ܔy9?9ڋFn +ɠsHpFj FεD.CMT,s B ;찄f&9Y7ˁ̄JMp6Je jcZ5Sr)S]d2w|+-I;2‹i*7Ns'D&L$#l\Y'3~:#6vђ6Oka(Vo>3F[7!܈,#|^D[+Iw߻ߋ҅OWa!jϟ톿 رQ=8dd\"ɏ.D+A|.S^T:m{PԖkV(] ?Ju,(މv}hm 2A{FoqFe^Ǿ/Qb.Py崿I ـ0^m :*8: pbNWC}Q'*2YVߕOae ^ɝW V]X6$BM dR4Ry;`"2 c{D{1~G/ XOnV\XA}UY+kz42Ys*y N726:Ke\,s t@\‹Fbu{ lK,#LgeJ``-b[0$}4f^K6VL`Ϟ1\9BŤE9 ៨I 5xC'<|MoիK? i=*Z+4;{L!i!<gIz{{Jz< 4^\tx:7E\ġ$r.얾+gw4P!0L1&64Ch* >XWp MR7,9)vԎ"KdъԫvH/רi:iӱ*Ӛ:/|Mu(7MO$ ^bQ\mYUu<%w$$'2v!H%usջzOYV"$`T/QQniv/h7j7>\_~Vl۱FC3"ȠN-}iu[CP2M,}Ud. ao'`wx`ۡQQ5 QGO .BEȭuB3QY{ Ҟ4ۢxYiZ[}̿Nn|7F2aEPI`BTUEoQDrbp:6󬴍{@Pgڿ,o(QLoA%bPK!H$eO&awsrightsizer-1.0.7.2.dist-info/RECORDKw0ṿa(r `* ۯ?Wϻ֮hq5՛Z, )]1n{M̶~me ~P5h%ׂ"MUhRFy>yM*zu?6QL RoC\P#YʾjP74wFٓwJTlYlH48kLk5 @SQcۑOx-?BH'PYԈO- fyNБ)>s62-L\ï4D֥(-5dHq- %tijd_6ރ?JԷ` *H]7|bh?~^c[:KhqB.^yb4#O] -APK!J |PPrightsizer/AwsRightSizer.pyPK!rightsizer/__init__.pyPK!g/p@@rightsizer/main.pyPK!HO*30awsrightsizer-1.0.7.2.dist-info/entry_points.txtPK!l.P,P,'nawsrightsizer-1.0.7.2.dist-info/LICENSEPK!HW"TT%Gawsrightsizer-1.0.7.2.dist-info/WHEELPK!HV(Gawsrightsizer-1.0.7.2.dist-info/METADATAPK!H$eO&Pawsrightsizer-1.0.7.2.dist-info/RECORDPK}R