术语 'Events:' 在 AWS 的 cloudformation 模板中无法识别
The term 'Events:' is not recognized in cloudformation template in AWS
我正在尝试 SAM 无服务器框架。
一直在学习教程。我遵循的步骤
- 创建了 SAM 模板。
- 将SAM模板转换为云形成模板并存储在S3中
- 尝试部署从转换中生成的云形成模板。
下面是转换后的云层模板:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Demo For SAM !!!
Globals:
Function:
MemorySize: 128
Runtime: Python 3.6
Timeout: 5
Resources:
display:
Type: AWS::Serverless::Function
Properties:
Handler: display.lambda_handler
Events:
GetLogs:
Type: Api
Properties:
Path: /call
Method: get
CodeUri: s3://sumanth-sam/debb239335f6dcf3f3f146367295b556
add:
Type: AWS::Serverless::Function
Properties:
Handler: add.lambda_handler
Events:
Add:
Type: Api
Properties:
Path: /add
Method: post
CodeUri: s3://sumanth-sam/debb239335f6dcf3f3f146367295b556
Cloud formation 堆栈因以下错误进入回滚状态。
Events:
Events: : The term 'Events:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ Events:
+ ~~~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> GetLogs:
GetLogs: : The term 'GetLogs:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:9
+ GetLogs:
+ ~~~~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> Type: Api
Type: : The term 'Type:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:11
+ Type: Api
+ ~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> Properties:
Properties: : The term 'Properties:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:11
+ Properties:
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Properties::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> Path: /call
Path: : The term 'Path:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:13
+ Path: /call
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (Path::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我觉得问题可能出在模板的结构上(无法确定)。或者我可能会使用一些过时的方法。
谁能帮我解决这个问题。
检查Globals
部分下的Runtime
,Python
和3.6
之间有一个space。
试试这个
Globals:
Function:
MemorySize: 128
Runtime: Python3.6
Timeout: 5
建议在编写模板时尝试 CloudFormation Linter in VSCode 以查看其中一些内联错误:
E3030 You must specify a valid value for Runtime (Python 3.6).
Valid values are ["dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java8", "java8.al2", "java11", "nodejs", "nodejs4.3-edge", "nodejs4.3", "nodejs6.10", "nodejs8.10", "nodejs10.x", "nodejs12.x", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "ruby2.5", "ruby2.7"]
我正在尝试 SAM 无服务器框架。 一直在学习教程。我遵循的步骤
- 创建了 SAM 模板。
- 将SAM模板转换为云形成模板并存储在S3中
- 尝试部署从转换中生成的云形成模板。
下面是转换后的云层模板:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Demo For SAM !!!
Globals:
Function:
MemorySize: 128
Runtime: Python 3.6
Timeout: 5
Resources:
display:
Type: AWS::Serverless::Function
Properties:
Handler: display.lambda_handler
Events:
GetLogs:
Type: Api
Properties:
Path: /call
Method: get
CodeUri: s3://sumanth-sam/debb239335f6dcf3f3f146367295b556
add:
Type: AWS::Serverless::Function
Properties:
Handler: add.lambda_handler
Events:
Add:
Type: Api
Properties:
Path: /add
Method: post
CodeUri: s3://sumanth-sam/debb239335f6dcf3f3f146367295b556
Cloud formation 堆栈因以下错误进入回滚状态。
Events:
Events: : The term 'Events:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:1
+ Events:
+ ~~~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> GetLogs:
GetLogs: : The term 'GetLogs:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:9
+ GetLogs:
+ ~~~~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> Type: Api
Type: : The term 'Type:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:11
+ Type: Api
+ ~~~~~
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> Properties:
Properties: : The term 'Properties:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and try again.
At line:1 char:11
+ Properties:
+ ~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Properties::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\asus\OneDrive\Desktop\SAM\sam_demo> Path: /call
Path: : The term 'Path:' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At line:1 char:13
+ Path: /call
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (Path::String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我觉得问题可能出在模板的结构上(无法确定)。或者我可能会使用一些过时的方法。 谁能帮我解决这个问题。
检查Globals
部分下的Runtime
,Python
和3.6
之间有一个space。
试试这个
Globals:
Function:
MemorySize: 128
Runtime: Python3.6
Timeout: 5
建议在编写模板时尝试 CloudFormation Linter in VSCode 以查看其中一些内联错误:
E3030 You must specify a valid value for Runtime (Python 3.6).
Valid values are ["dotnetcore1.0", "dotnetcore2.0", "dotnetcore2.1", "dotnetcore3.1", "go1.x", "java8", "java8.al2", "java11", "nodejs", "nodejs4.3-edge", "nodejs4.3", "nodejs6.10", "nodejs8.10", "nodejs10.x", "nodejs12.x", "provided", "provided.al2", "python2.7", "python3.6", "python3.7", "python3.8", "ruby2.5", "ruby2.7"]