def return_resource_name(self, record, resource_type):
        """ Removes the trailing AWS domain from a DNS record
            to return the resource name

            e.g bucketname.s3.amazonaws.com will return bucketname

        Args:
            record (str): DNS record
            resource_type: AWS Resource type (i.e. S3 Bucket, Elastic Beanstalk, etc..)

        """
        try:
            if resource_type == 's3':
                regex = re.compile('.*(\.(?:s3-|s3){1}(?:.*)?\.amazonaws\.com)')
                bucket_name = record.replace(regex.match(record).group(1), '')
                return bucket_name

        except Exception as e:
            self.log.error('Unable to parse DNS record {} for resource type {}/{}'.format(record, resource_type, e))
            return record
Removes the trailing AWS domain from a DNS record
            to return the resource name

            e.g bucketname.s3.amazonaws.com will return bucketname

        Args:
            record (str): DNS record
            resource_type: AWS Resource type (i.e. S3 Bucket, Elastic Beanstalk, etc..)