【问题标题】:cloudformation validation returns: Invalid template resource propertycloudformation 验证返回:无效的模板资源属性
【发布时间】:2017-12-23 15:13:15
【问题描述】:

考虑云形成模板的这一部分:

# VPC
    myVPC:
      Type: "AWS::EC2::VPC"
      Properties:
        CidrBlock: 10.99.99.0/24

# Security group

    http_sec_group:
      Type: "AWS::EC2::SecurityGroup"
      Properties: 
        GroupName: http_in
        GroupDescription: "Allow http traffic inbound"
        VpcId: !Ref myVPC
        SecurityGroupIngress:
          - ToPort: 80
            IpProtocol: tcp

验证它会返回此错误:

调用ValidateTemplate操作时发生错误(ValidationError):无效的模板资源属性'myVPC'

语法看起来正确,但为什么引用返回错误?

【问题讨论】:

  • 我的 yml 文件没有使用引号:类型:AWS::EC2::VPC。 yml 格式是否正确?
  • 您分享的模板看起来不错。如果您可以共享整个模板,将会很有帮助。

标签: amazon-cloudformation


【解决方案1】:

错误提示“无效的模板资源属性”。这是因为您的完整模板文件可能由于间距问题而格式错误,并且 CloudFormation 正在考虑将“myVPC”作为先前声明的资源的属性。

here 提供了有关此错误的更多信息。

此外,您的安全组资源逻辑 ID 无效,因为逻辑 ID 必须是字母数字。更多info

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-15
    • 1970-01-01
    • 2018-03-26
    • 2020-10-21
    • 2016-09-30
    • 1970-01-01
    • 2016-03-19
    相关资源
    最近更新 更多