跳至内容

如何对 CloudFormation 模块错误进行故障排除?

1 分钟阅读
0

我想解决我在 AWS CloudFormation 中遇到的模块错误。

解决方法

CloudFormation 模块有助于将基础设施简化为代码。它们在整个堆栈模板中提供透明度和可管理性。但是,在创建和使用模块的过程中,您可能会遇到错误。

错误: “Module fragment might be valid, but there are warnings from cfn-lint: Invalid Property Resources/<Resource-Name>/Properties/<PropertyName>.Did you mean <Valid-PropertyName>? (from rule E3002: Resource properties are invalid)”(模块片段可能有效,但有来自 cfn-lint 的警告:无效的属性资源//属性/。您的意思是?(来自规则 E3002:资源属性无效))

创建模块时可能会出现此错误。

要解决此错误,请执行以下步骤:

  1. 确保 CloudFormation 模板有效。

    使用 GitHub 网站上的 CloudFormation Linter 验证片段文件夹中的模板。在创建模块之前使用它来尽早发现潜在问题。

  2. 如果有任何其他错误,请检查在 CloudFormation 模块初始化期间创建的 rpdk.log 文件。

    rpdk.log 文件包含运行 cfn 命令时生成的详细日志。分析日志,以深入了解操作顺序和潜在错误。

错误: “Properties validation failed for resource <stack-name> with message: #/<Property>: failed validation constraint for keyword [pattern]”(资源属性验证失败并显示消息:#/:关键字 [pattern] 的验证约束失败)


当您使用该模块时,可能会出现此错误。验证属性验证失败的来源。

  1. 检查参数约束。

    确保属性满足指定的参数约束。这包括创建模块时使用的 CloudFormation 模板的数据类型和模式。

  2. 检查资源属性约束。

    调查 CloudFormation 模板中对实际资源属性的约束。

    在 CloudFormation 模块模板参数中将 Amazon Simple Storage Service (Amazon S3) 存储桶名称设置为无约束的测试会导致验证错误。输入符合参数约束,但由于输入使用大写字母,因此违反了 S3 存储桶命名规范。

相关信息

AWS CloudFormation 模块简介

使用模块封装和重用资源配置

CloudFormation CLI 命令参考

AWS 官方已更新 3 年前