1

我是 AWS SAM 部署的新手。我有一个使用 SAM AWS 自动部署的用例。拥有一个带有另一个 HTTP 端点调用的 Rest API GW。我搜索了更多文档,但没有找到任何解决方案。你能建议我怎么做这个案子吗?

提前致谢。卡西克扬 B

4

2 回答 2

1

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

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

于 2020-06-22T04:10:10.533 回答
0
  1. 您可以使用 VS Code 中的 AWS 工具包单击几下构建一个 hello world SAM 应用程序,如我在此处的博客文章中所示。
  2. 然后,修改生成的 SAM 模板 ( template.yaml) 以与 HTTP API 而不是 Lambda 集成。
  3. 添加buildspec.yml到您的代码库并使用 AWS CodeBuild 和 CodePipeline 构建 CI/CD 管道,如我在此处的博客文章中所示。
于 2020-06-23T16:53:28.033 回答