Search code examples
amazon-web-servicesaws-api-gatewaysam

AWS SAM Deploy, how to find URL of API Gateway?


How do I find the URL address of the API Gateway after deployment from Command line ?

I use a script similar to below to deploy my API Gateway and Authorizer, and it deploys fine.

https://github.com/floodfx/aws-lambda-proxy-using-sam-local/blob/master/deploy.sh

I'm trying to figure out how to get the address of the API Gateway after Deployment from the command line

The API Gateway gets created, I can see the stack:

aws cloudformation describe-stacks
"Stacks": [
        {
            "StackId": "arn:aws:cloudformation:us-east-1:761861444952:stack/mygateway912/72100720-6e67-11e8-93e9-500c28604c4a", 
            "Description": "An example serverless \"Hello World2 \" application with a custom authorizer.", 
            "Tags": [], 
            "CreationTime": "2018-06-12T17:38:40.946Z", 
            "Capabilities": [
                "CAPABILITY_IAM"
            ], 
            "StackName": "mygateway912", 
            "NotificationARNs": [], 
            "StackStatus": "CREATE_COMPLETE", 
            "DisableRollback": false, 
            "ChangeSetId": "arn:aws:cloudformation:us-east-1:76161444952:changeSet/awscli-cloudformation-package-deploy-1528825120/352f7c7a-2870-44ea-9e7f-40d16c0015df", 
            "LastUpdatedTime": "2018-06-12T17:38:46.411Z"
        }

There must be a simple command I'm missing to get this.


Solution

  • I just had time to answer properly. Having API Gateway definition:

    Resources:
      ...
      ServerlessRestApi:
        Type: AWS::Serverless::Api
        DeletionPolicy: "Retain"
        Properties:
          StageName: Prod
      ...
    

    you can output

    Outputs:
      ProdDataEndpoint:
        Description: "API Prod stage endpoint"
        Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"