【问题标题】:Setting HTTP Proxy on AWS API Gateway via Cloudformation通过 Cloudformation 在 AWS API Gateway 上设置 HTTP 代理
【发布时间】:2018-01-27 02:04:52
【问题描述】:

提前感谢您的帮助。

目前使用 cloudformation 模板将简单的 API 部署到 AWS,作为 POC 的一部分,以便从 Azure 迁移到 AWS API 管理。

除了我无法弄清楚用于设置 HTTP 请求的 HTTP 代理复选框的 YAML AWS 扩展之外,我已经完成了所有工作。

下面的示例 YAML。我知道这不会设置该复选框(因为我已经对其进行了测试并且它可以解决该问题),但是在此页面上

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-integration.html

我看不到设置此选项的扩展程序? AWS 还没有这样做吗

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  PlayersAPI:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: RAH API
      Description: A demo API for testing
      Body:
        swagger: '2.0'
        info:
          title: test api
          description: test api
          version: 1.0.1
          contact:
            name: SH
            email: test@mailinator.com
        paths:
          "/heartbeat":
            get:
              description: Checks the API is working
              produces:
              - application/json
              responses:
                '200':
                  description: API Response information
              x-amazon-apigateway-integration:
                type: http
                responses:
                  default:
                    statusCode: '200'
                httpMethod: GET
                uri: https://api.example.com

【问题讨论】:

  • 出于好奇,从 Azure API 管理迁移的动机是什么?也许我们可以帮忙?
  • 尤里卡! (那是宾果游戏的澳大利亚人!)非常感谢汤姆。另一方面,@DarrelMiller - 主要原因是成本。你们不是基于每月 750 美元的最低消费,根据我们当前的数据使用情况,我们的 AWS 估计每月费用为 150-200 美元。我知道您有每月 22 次的选项,但 1) 没有 SLA 2) 不适合生产。所以这里的价格真的让你失望了。我们喜欢 Azure 的 API 管理,但在管理方面,$ 会说话。
  • @user2058234 是的,我明白了。这也是我们身边的一根真正的刺。
  • 所以@DarrelMiller 认为你可能会喜欢这个更新。我们坚持使用 Azure 和它,因为我们在 AWS 中发现了一个缺陷,如果 API 超时时间超过 30 秒,它就会失效。我们的 API 是独一无二的,因为它需要延长处理时间才能完成 azure 提供的任务。请永远不要改变它:)

标签: azure amazon-web-services yaml aws-api-gateway azure-api-management


【解决方案1】:

这对我有用:

resources:
  Resources:
    ProxyResource:
      Type: AWS::ApiGateway::Resource
      Properties:
        ParentId:
          Fn::GetAtt:
            - ApiGatewayRestApi # our default Rest API logical ID
            - RootResourceId
        PathPart: "{proxy+}" # the endpoint in your API that is set as proxy
        RestApiId:
          Ref: ApiGatewayRestApi
    ProxyMethod:
      Type: AWS::ApiGateway::Method
      Properties:
        ResourceId:
          Ref: ProxyResource
        RestApiId:
          Ref: ApiGatewayRestApi
        HttpMethod: GET # the method of your proxy. Is it GET or POST or ... ?
        MethodResponses:
          - StatusCode: 200
        Integration:
          IntegrationHttpMethod: GET
          Type: HTTP_PROXY
          Uri: http://bucket.mybucket.co.s3.eu-west-1.amazonaws.com/{proxy} # the URL you want to set a proxy to
          IntegrationResponses:
            - StatusCode: 200
        AuthorizationType: NONE

【讨论】:

    猜你喜欢
    • 2019-02-03
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 2018-05-25
    • 2021-08-14
    • 2016-12-07
    • 1970-01-01
    • 2017-01-28
    相关资源
    最近更新 更多