【问题标题】:AWS CLI command to execute the API Gateway用于执行 API 网关的 AWS CLI 命令
【发布时间】:2020-08-10 00:11:13
【问题描述】:

我正在尝试在 EC2 实例中使用 AWS CLI 执行 API 网关。我在 AWS CLI 文档中没有找到任何命令。 有没有人使用过 CLI 来执行 API 网关端点?

谢谢

【问题讨论】:

    标签: amazon-web-services aws-api-gateway aws-cli


    【解决方案1】:

    遗憾的是,在 CLI 或 SDK 中没有这样的 API 调用。您必须使用外部工具来调用您的 API。

    例如,curlpostmanrequests python 中的包。

    例如,如果您通过aws_iam 保护您的API,您可以在python 中使用AWSRequestsAuth 来构造有效的AWS IAM 请求。在postman 中,您还可以为此类 API 的请求提供 IAM 凭证。

    【讨论】:

      【解决方案2】:

      现在可以使用 AWS CLI 版本 2。

      https://docs.aws.amazon.com/cli/latest/reference/apigateway/test-invoke-method.html

      这是一个使用文件作为请求正文的示例测试 POST:

      aws --region us-west-2 apigateway test-invoke-method --rest-api-id abcd1234 --resource-id abcd12 --http-method POST --path-with-query-string '/records/create' --body file://test-body.json
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-04-20
        • 1970-01-01
        • 1970-01-01
        • 2021-10-08
        • 1970-01-01
        • 1970-01-01
        • 2020-09-29
        相关资源
        最近更新 更多