def allow_access_to_instance(self, _, ip_address):
        ''' Allow access to instance. '''
        if not self.connect_to_aws_rds():
            return False
        try:
            conn = boto.ec2.connect_to_region(
                self.region,
                aws_access_key_id=self.aws_access_key_id,
                aws_secret_access_key=self.aws_secret_access_key
            )
            sgs = conn.get_all_security_groups('default')
            default_sg = sgs[0]
            default_sg.authorize(ip_protocol='tcp', from_port=3306,
                                 to_port=3306, cidr_ip=str(ip_address)+'/32')
        except EC2ResponseError, exception:
            if exception.error_code == "InvalidPermission.Duplicate":
                return True  # ok it already exists
            else:
                return False
        else:
            return True
def allow_access_to_instance ( self , _ , ip_address ) : if not self . connect_to_aws_rds ( ) : return False try : conn = boto . ec2 . connect_to_region ( self . region , aws_access_key_id = self . aws_access_key_id , aws_secret_access_key = self . aws_secret_access_key ) sgs = conn . get_all_security_groups ( 'default' ) default_sg = sgs [ 0 ] default_sg . authorize ( ip_protocol = 'tcp' , from_port = 3306 , to_port = 3306 , cidr_ip = str ( ip_address ) + '/32' ) except EC2ResponseError , exception : if exception . error_code == "InvalidPermission.Duplicate" : return True else : return False else : return True
Allow access to instance.