相关疑难解决方法(0)

如何在 SAM template.yml 中包含多个资源文件

我想将我的云形成 yml 文件写入不同的文件中并单独加载它们。在无服务器框架中很容易做到这一点,但我不知道如何使用 SAM 做到这一点。你介意帮我怎么做吗?

我提供了以下项目的副本:

https://github.com/day2daychallenge/nest_application.git

我的 template.yml 文件:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Sample SAM Template

# Create our resources with separate CloudFormation templates
resources:
  Resources:
    # Lambda function
    - ${file(resources/lambda-functions.yml)}
Run Code Online (Sandbox Code Playgroud)

我的资源文件(lambda-functions.yml)如下:

  HelloWorldFunction:
    Type: AWS::Serverless::Function 
    Properties:
      CodeUri: hello-world/
      Handler: app.lambdaHandler
      Runtime: nodejs12.x
      Events:
        HelloWorld:
          Type: Api 
          Properties:
            Path: /helloworld
            Method: get
Run Code Online (Sandbox Code Playgroud)

我的文件夹结构。 在此输入图像描述

编辑4:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  Sample SAM Template

# Create our resources with separate CloudFormation templates resources:
Resources:
  yourApplicationAliasName:
    Type: AWS::Serverless::Application
    Properties:
      # …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services aws-lambda aws-sam

10
推荐指数
1
解决办法
2万
查看次数

标签 统计

amazon-web-services ×1

aws-lambda ×1

aws-sam ×1