amazon-web-services - AWS 的 cloudformation 模板中无法识别术语“事件:”
问题描述
我正在尝试使用 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
云形成堆栈将因以下错误而回滚。
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
我觉得问题可能出在模板的结构上(无法查明)。或者我可能会使用一些过时的方法。谁能帮我解决这个问题。
解决方案
建议在 VSCode 中尝试CloudFormation Linter,以在创作模板时内联查看其中一些错误:
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"]
推荐阅读
- json - JSON 到 CSV - 深入 4 级
- svg - 当您更改指针事件时,Svg texpath 在 Firefox 中消失
- c# - C# - 使用 foreach 和 if 语句循环遍历 DataGridView 行 - 缺少最后一个条目
- ruby - Ruby:如何在不使用 ActiveSupport 的情况下对字符串进行 dasherize
- function - MS Word“和”功能
- javascript - 在javascript中按值过滤对象数组
- javascript - 显示未定义的 Django ajax 的外键
- sql - 为什么 postgresql case 语句的结果在 where 子句中不起作用
- windows - Xbox UWP 内存使用限制
- javascript - 如何停止用户点击的影响?