use*_*307 7 sam amazon-web-services aws-api-gateway
从命令行部署后如何找到API网关的URL地址?
我使用类似于下面的脚本来部署我的API网关和授权器,它部署得很好.
https://github.com/floodfx/aws-lambda-proxy-using-sam-local/blob/master/deploy.sh
我试图弄清楚如何从命令行获取部署后的API网关的地址
API网关被创建,我可以看到堆栈:
aws cloudformation describe-stacks
Run Code Online (Sandbox Code Playgroud)
https://github.com/floodfx/aws-lambda-proxy-using-sam-local/blob/master/deploy.sh
必须有一个简单的命令我不知道这个.
我有时间正确回答.拥有API网关定义:
Resources:
...
ServerlessRestApi:
Type: AWS::Serverless::Api
DeletionPolicy: "Retain"
Properties:
StageName: Prod
...
Run Code Online (Sandbox Code Playgroud)
你可以输出
Outputs:
ProdDataEndpoint:
Description: "API Prod stage endpoint"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"
Run Code Online (Sandbox Code Playgroud)
我有独立AWS::ApiGateway::RestApi和AWS::ApiGateway::Stage资源,所以我看了输出有点不同,因为我没有/不能硬编码艺名:
Outputs:
ProdEndpoint:
Value: !Sub "https://${ApiGw}.execute-api.${AWS::Region}.amazonaws.com/${ApiGwStage}/"
Resources:
ApiGw:
Type: AWS::ApiGateway::RestApi
Properties:
Name: 'Serverless Ipsum #noServerNovember challenge'
FailOnWarnings: true
ApiGwDeployment:
Type: AWS::ApiGateway::Deployment
# Required -- see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-deployment.html
DependsOn: ApiGwMethod
Properties:
RestApiId: !Ref ApiGw
ApiGwStage:
Type: AWS::ApiGateway::Stage
Properties:
DeploymentId: !Ref ApiGwDeployment
MethodSettings:
- DataTraceEnabled: true
HttpMethod: '*'
LoggingLevel: INFO
ResourcePath: '/*'
RestApiId: !Ref ApiGw
StageName: prod
ApiGwResource:
Type: AWS::ApiGateway::Resource
Properties:
RestApiId: !Ref ApiGw
ParentId: !GetAtt ["ApiGw", "RootResourceId"]
PathPart: "{proxy+}"
ApiGwMethod:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref ApiGw
ResourceId: !Ref ApiGwResource
HttpMethod: ANY
AuthorizationType: NONE
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ServerlessIpsumFunction.Arn}/invocations"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4678 次 |
| 最近记录: |