amazon-web-services - AWS Cloudformation - 将 VPC_Link/NLB 附加到 api 网关中的方法会出现 "Invalid method setting path"错误

标签 amazon-web-services aws-cloudformation aws-api-gateway amazon-elb

我正在尝试使用 CloudFormation 来部署具有 VPC Link 和 NLB 的 API Gateway。目标是将所有请求代理传递到 NLB:

  NLB:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties: 
      Type: "network"
      IpAddressType: "ipv4"
      Name: !Ref NLBName
      Scheme: "internal"
      # LoadBalancerAttributes: 
      #   - LoadBalancerAttribute
      Subnets: 
        - !Ref NLBSubnetApNortheast1a
        - !Ref NLBSubnetApNortheast1c
        - !Ref NLBSubnetApNortheast1d

  ... other code ... 

  ApiProxyMethod: 
    Type: AWS::ApiGateway::Method
    Properties: 
      RestApiId: !Ref ApiGatewayRestApi
      ResourceId: !Ref ApiProxyResource
      AuthorizationType: COGNITO_USER_POOLS
      AuthorizerId: !Ref ApiAuthorizer
      HttpMethod: ANY
      OperationName: "ProxyAllRequests"
      Integration: 
        ConnectionType: VPC_LINK
        ConnectionId: !Ref ApiGatewayVpcLink
        IntegrationHttpMethod: ANY
        # PassthroughBehavior: String        
        Type: "HTTP" # Member must satisfy enum value set: [HTTP, AWS_PROXY, HTTP_PROXY, AWS] 
        Uri: !Sub 
          - 'http://${DNSName}/{proxy}'
          - DNSName: !GetAtt NLB.DNSName
          # DNSName: The DNS name for the load balancer. For example, my-load-balancer-424835706.us-west-2.elb.amazonaws.com

当我尝试运行它时,出现以下错误: enter image description here

错误详细信息:

1 validation error detected: Value 'Invalid method setting path: 
null/null/logging/dataTrace. Must be one of: [/deploymentId, 
/description, /cacheClusterEnabled, /cacheClusterSize, 
/clientCertificateId, /accessLogSettings, 
/accessLogSettings/destinationArn, /accessLogSettings/format, 
/{resourcePath}/{httpMethod}/metrics/enabled, 
/{resourcePath}/{httpMethod}/logging/dataTrace, 
/{resourcePath}/{httpMethod}/logging/loglevel, 
/{resourcePath}/{httpMethod}/throttling/burstLimit/{resourcePath}/{ht
tpMethod}/throttling/rateLimit/{resourcePath}/{httpMethod}/caching/t
tlInSeconds, /{resourcePath}/{httpMethod}/caching/enabled,
 /{resourcePath}/{httpMethod}/caching/dataEncrypted, /{resourcePath}/{httpMethod}/caching/requireAuthorizationForCacheControl, 
/{resourcePath}/{httpMethod}/caching/unauthorizedCacheControlHeaderStrategy, /*/*/metrics/enabled, /*/*/logging/dataTrace, 
/*/*/logging/loglevel, /*/*/throttling/burstLimit 
/*/*/throttling/rateLimit /*/*/caching/ttlInSeconds, 
/*/*/caching/enabled, /*/*/caching/dataEncrypted, 
/*/*/caching/requireAuthorizationForCacheControl, 
/*/*/caching/unauthorizedCacheControlHeaderStrategy, 
/variables/{variable_name}, /tracingEnabled] (Service: ApiGateway, 
Status Code: 400, Request ID: 748f725f-fa59-4885-9058-9d4d17722d5e, 
Extended Request ID: null)' at 'statusMessage' failed to satisfy 
constraint: Member must have length less than or equal to 1024


我能够找到错误来源为 AWS::ApiGateway::Method,并且 Uri 似乎不正确。

当我将 Uri 更改为 "http://NLB-myapp-internal-beta-123.elb.ap-northeast-1.amazonaws.com/{proxy} 时“,一切正常。

我试图搜索错误消息,但没有任何线索。 可能是什么原因?错误消息是什么意思?

最佳答案

我认为应该是:

        Type: HTTP_PROXY 
        Uri: !Sub "http://${NLB.DNSName}"

您不需要任何{proxy}

关于amazon-web-services - AWS Cloudformation - 将 VPC_Link/NLB 附加到 api 网关中的方法会出现 "Invalid method setting path"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72017261/

相关文章:

amazon-web-services - 使用 aws-load-balancer-backend-protocol : "https" 时,nginx-ingress 不适用于 AWS ELB

javascript - AWS - 导入 JSON 文件以加载 Dynamo 表

amazon-web-services - 创建 AWS Lambda 函数时使用现有 IAM 角色

aws-lambda - 当我尝试使用方法 OPTIONS 进行 CORS 预检 (Lambda) 时,AWS cloudformation template.yaml 失败

amazon-web-services - AWS API Gateway - CORS "access-control-allow-origin"- 多个条目

amazon-web-services - 如何在CloudFormation中创建可变计数资源?

aws-cloudformation - 在 Cloudformation 中使用 AWS Secrets Manager 的 Secret

amazon-web-services - AWS 云形成 "API: autoscaling:CreateAutoScalingGroup "

amazon-web-services - 如何通过 IP 限制 AWS Lambda 或 API Gateway?

aws-lambda - AWS Lambda 和网关 API - 使用 cloudformation 进行蓝/绿部署