'Given a lambda_name, return the API id.'

def get_api_id(self, lambda_name):

    try:
        response = self.cf_client.describe_stack_resource(StackName=lambda_name, LogicalResourceId='Api')
        return response['StackResourceDetail'].get('PhysicalResourceId', None)
    except:
        try:
            response = self.apigateway_client.get_rest_apis(limit=500)
            for item in response['items']:
                if (item['name'] == lambda_name):
                    return item['id']
            logger.exception('Could    not    get    API    ID.')
            return None
        except:
            return None
