最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

为Amazon ApiGateway中的URI指定了无效的HTTP端点

运维笔记admin6浏览0评论

为Amazon ApiGateway中的URI指定了无效的HTTP端点

为Amazon ApiGateway中的URI指定了无效的HTTP端点

我正在尝试使用cloudformation模板使用API​​网关的GET方法创建资源/ user / devices,但它给了我以下错误

发生错误:ApiGatewayRootMethod-为URI指定了无效的HTTP端点(服务:AmazonApiGateway;状态代码:400;错误代码:BadRequestException;请求ID:xxxxxxxxxx)

下面是我的cloudformation模板,

AWSTemplateFormatVersion: 2018-11-13
Description: test user

resources:
  Resources:

    UserDeviceApiGateway:
      Type: "AWS::ApiGateway::RestApi"
      Properties:
        Name: "test-user-info"
        Description: "Fetch the user"

    UserResource:
      Type: 'AWS::ApiGateway::Resource'
      Properties:
        ParentId:
          Fn::GetAtt: ["UserDeviceApiGateway","RootResourceId"]
        RestApiId:
          Ref: "UserDeviceApiGateway"
        PathPart: 'user'

    Resource:
      Type: 'AWS::ApiGateway::Resource'
      Properties:
        ParentId:
          Ref: "UserResource"
        RestApiId:
          Ref: "UserDeviceApiGateway"
        PathPart: 'devices'

    ApiGatewayRootMethod:
      Type: "AWS::ApiGateway::Method"
      Properties:
        AuthorizationType: "NONE"
        HttpMethod: "GET"
        Integration:
          IntegrationHttpMethod: "GET"
          Type: "HTTP"
          Uri: Sub
            - "arn:aws:apigateway:arn:aws:lambda:eu-west-1:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-1:xxxxxxxx:function:user-device-lambda/invocations"
        ResourceId:
          Fn::GetAtt: ["UserDeviceApiGateway","RootResourceId"]
        RestApiId:
          Ref: "UserDeviceApiGateway"

    Deployment:
      DependsOn:
        - ApiGatewayRootMethod
      Type: 'AWS::ApiGateway::Deployment'
      Properties:
        RestApiId:
          Ref: "UserDeviceApiGateway"
        StageName: dev
回答如下:聚会晚了一点,但是...

您为Type: "HTTP"指定了ApiGatewayRootMethod,但HTTP接受了API端点URL。您指定的URI格式由Type: "AWS"获取。

从AWS文档:

用于集成的统一资源标识符(URI)。

如果为Type属性指定HTTP,请指定API端点URL。

如果为Type属性指定MOCK,请不要指定此属性。

如果为Type属性指定AWS,请指定遵循以下形式的AWS服务:arn:aws:apigateway:region:subdomain.service | service:path | action / service_api。例如,Lambda函数URI遵循以下格式:arn:aws:apigateway:region:lambda:path / path。该路径通常采用/ 2015-03-31 / functions / LambdaFunctionARN / invocations的形式。有关更多信息,请参阅Amazon API Gateway REST API参考中的集成资源的uri属性。

如果您为Type属性指定HTTP或AWS,则必须指定此属性。

https://docs.aws.amazon/AWSCloudFormation/latest/UserGuide/aws-properties-apitgateway-method-integration.html

发布评论

评论列表(0)

  1. 暂无评论