Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 为Amazon API网关中的URI指定的HTTP终结点无效_Node.js_Amazon Web Services_Aws Api Gateway_Serverless Framework_Aws Serverless - Fatal编程技术网

Node.js 为Amazon API网关中的URI指定的HTTP终结点无效

Node.js 为Amazon API网关中的URI指定的HTTP终结点无效,node.js,amazon-web-services,aws-api-gateway,serverless-framework,aws-serverless,Node.js,Amazon Web Services,Aws Api Gateway,Serverless Framework,Aws Serverless,我正在尝试使用cloudformation模板为API网关创建一个带有GET方法的资源/用户/设备,但它给了我以下错误 出现错误:ApiGatewayRootMethod-为URI指定的HTTP终结点无效(服务:AmazonApiGateway;状态代码:400;错误代码:BadRequestException;请求ID:xxxxxxxxx) 下面是我的cloudformation模板 AWSTemplateFormatVersion: 2018-11-13 Description: test

我正在尝试使用cloudformation模板为API网关创建一个带有GET方法的资源/用户/设备,但它给了我以下错误

出现错误:ApiGatewayRootMethod-为URI指定的HTTP终结点无效(服务:AmazonApiGateway;状态代码:400;错误代码:BadRequestException;请求ID:xxxxxxxxx)

下面是我的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

派对有点晚了但是

您可以为
ApiGatewayRootMethod
指定
类型:“HTTP”
,但HTTP采用API端点URL。指定的URI格式由
类型:“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。有关更多信息,请参阅AmazonAPI网关RESTAPI参考中集成资源的uri属性

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


你有没有找到答案?