使用 SAM AWS 通过 HTTP 端点集成部署 REST API?

Deploy REST API with HTTP Endpoint Integration using SAM AWS?

我是 AWS SAM 部署的新手。我有一个使用 SAM AWS 自动化部署的用例。使用另一个 HTTP 端点调用的 Rest API GW。我搜索了更多文档,但没有找到任何解决方案。你介意建议我如何处理这个案例吗?

提前致谢。 Karthikeyan B

您可以尝试创建集成的示例模板 -

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS SAM template with a HTTP integration
Resources:
  ApiGatewayApi:
    Type: AWS::Serverless::Api
    Properties:
      StageName: prod
      DefinitionBody: {
        "swagger": "2.0",
        "info": {
          "version": "1.0"
        },
        "paths": {
          "test": {
            "get": {
              "produces": [
                "application/json"
              ],
              "responses": {
                "200": {
                  "description": "200 response"
                }
              },
              "x-amazon-apigateway-integration": {
                "responses": {
                  "default": {
                    "statusCode": "200"
                  }
                },
                "credentials": "arn:aws:iam::account-id:role/role-name",
                "uri": "https://www.example.com",
                "passthroughBehavior": "when_no_match",
                "httpMethod": "GET",
                "type": "http_proxy"
              }
            }
          }
        }
    }

使用 CLI -

部署模板

$ sam deploy --stack-name httpProxy -t httpProxy.yaml --capabilities CAPABILITY_IAM

  1. 如我的博客 post here.
  2. 所示,您可以使用 VS Code 中的 AWS 工具包单击几下即可构建一个 hello world SAM 应用程序
  3. 然后,修改生成的 SAM 模板 (template.yaml) 以与 HTTP API 而不是 Lambda 集成。
  4. buildspec.yml 添加到您的代码库并使用 AWS CodeBuild 和 CodePipeline 构建 CI/CD 管道,如我的博客 post here.
  5. 所示