Template format error: unsupported structure seen in AWS CloudFormation

Template format error: unsupported structure seen in AWS CloudFormation

我正在尝试使用如下命令验证 AWS 示例 CloudFormation 模板:

▶ aws cloudformation validate-template --template-body template.yml

这会导致以下错误消息:

An error occurred (ValidationError) when calling the ValidateTemplate operation:
  Template format error: unsupported structure. 

我在很多模板上都试过了,包括 AWS 文档中的示例模板。所以我知道模板没问题。

我做错了什么?

显然,非常无用的错误消息是由于 CLI 命令中格式不正确造成的。

--template-body 参数必须指定为 file URI

因此,上述命令的正确、可运行形式是:

▶ aws cloudformation validate-template --template-body file://template.yml

有关详细信息,请参阅 this 博客 post。

如果您正在使用 windows 文件系统,您可以这样使用:

--template-body file://c:/Windows/myfile.json

--template-body file://localhost/c$/Windows/myfile.json