1

嗨,我使用 nodejs express js 为我的 Web 应用程序创建了 post api,并使用 aws 无服务器开发过程,但是我遇到的问题是,当我添加一个以上的帖子时,选项和获取 api 比上次注册的 api 从 lambda api 网关中删除,因此我无法要访问以前的 api,我尝试了很多不同的解决方案,但还没有运气。

这里是我的 template.yml 代码,并附上了我的 lambda api 网关截图

AWSTemplateFormatVersion:2010-09-09 转换:-AWS::Serverless-2016-10-31-AWS::CodeStar

参数:ProjectId: 类型:String 描述:AWS CodeStar projectID 用于将新资源关联到团队成员

# Enable blue/green deployments using this Globals section. For instructions, see the AWS CodeStar User Guide:
# https://docs.aws.amazon.com/codestar/latest/userguide/how-to-modify-serverless-project.html?icmpid=docs_acs_rm_tr
#
# Globals:
#   Function:
#     AutoPublishAlias: live
#     DeploymentPreference:
#       Enabled: true
#       Type: Canary10Percent5Minutes

Resources:
  HelloWorld:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs6.10
      Environment:
        Variables:
          NODE_ENV: production
      Role:
        Fn::ImportValue:
          !Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
      Events:
        GetEvent:
          Type: Api
          Properties:
            Path: /
            Method: get
        PostEvent:
          Type: Api
          Properties:
            Path: /
            Method: post
        OptionsEvent:
          Type: Api
          Properties:
            Path: /savefundrisk
            Method: options
        PostEvent:
          Type: Api
          Properties:
            Path: /savefundrisk
            Method: post
        OptionsEvent:
          Type: Api
          Properties:
            Path: /saveUpdateLog
            Method: options
        PostEvent:
          Type: Api
          Properties:
            Path: /saveUpdateLog
            Method: post

lambda api 网关屏幕截图

4

0 回答 0