gpt4 book ai didi

amazon-web-services - 使用 aws-cli 创建 api-gateway lambda 集成

转载 作者:行者123 更新时间:2023-12-04 20:33:54 24 4
gpt4 key购买 nike

我需要使用 aws 客户端创建一个 api 网关。我使用 Web 控制台成功创建并集成了我的 aws-lambda 函数。但我对 aws-client 感到困惑。这些是我遵循的步骤。

  • 创建 api 网关并使用 Web 控制台与我的示例 lambda 函数集成。

  • enter image description here
  • 部署创建的 api 并导出为 json 文件。
  • 使用 aws-cli 使用导出的 json 文件创建新的 api 网关。这样的命令。
    aws apigateway import-rest-api --body file://tmpfile.json --region us-east-1;

  • 但它只创建了资源和方法。
  • 为了将 api 方法与我的 lambda 函数集成,我执行这样的命令
    aws apigateway put-integration --rest-api-id 42ku123id8u3a --resource-id core-api-dev --http-method DELETE --type AWS --integration-http-method POST --uri 'arn:aws:lambda:us-east-1:my-lambda-function-arn' --region us-east-1

    但它会产生这样的错误信息

  • An error occurred (NotFoundException) when calling the PutIntegration operation: Invalid Resource identifier specified



    是否可以使用 aws 客户端将 api 网关方法与现有的 lambda 函数集成?什么是资源标识符?

    最佳答案

    你可以运行 aws apigateway get-resources获取 resource-id

    aws apigateway get-resources --rest-api-id 42ku123id8u3a --region us-east-1

    它会返回一个 JSon 像
    {
    "items": [
    {
    "path": "/resource/xxx",
    "resourceMethods": {
    "POST": {}
    },
    "id": "_yourresourceid_",
    "pathPart": "xxx",
    "parentId": "ai5b02"
    }
    ]
    }

    您可以从这个 JSon 中获取 id 并将其用于您的命令 aws apigateway put-integration

    关于amazon-web-services - 使用 aws-cli 创建 api-gateway lambda 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39788094/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com