How do I find the API endpoint of a lambda function?

后端 未结 6 1577
有刺的猬
有刺的猬 2021-02-06 22:37

I have a Lambda function that has an exposed API Gateway endpoint, and I can get the URL for that via the AWS console. However, I would like to get that URL via API call. Neithe

6条回答
  •  粉色の甜心
    2021-02-06 22:51

    If you use CloudFormation you can get this with Python and Boto3:

    import boto3
    
    cloudformation = boto3.resource('cloudformation')
    stack = cloudformation.Stack(name=stack_name)
    api_url = next(
        output['OutputValue'] for output in stack.outputs
        if output['OutputKey'] == 'EndpointURL')
    

    This is from a working example of a REST service using Chalice that I put on GitHub. Here's a link to the pertinent code, in context: aws-doc-sdk-examples.

提交回复
热议问题