我想将我的云形成 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)