【问题标题】:Cloudformation Unresolved resource dependenciesCloudformation 未解决的资源依赖关系
【发布时间】:2020-01-10 19:46:37
【问题描述】:

我正在尝试构建我的第一个更大的 Cloudformation 模板;但是,我一直遇到图像选择过程的问题,因为它不喜欢我当前的配置。

我正在尝试让用户选择一个 Windows 操作系统版本,然后让 CFN 模板选择与此 Windows 版本匹配的 AMI。

yaml    
Mappings: 
  ImageMapping: 
    WindowsImage: 
      Windows2008R2: ami-0d8a5c68b4550ced5
      Windows2012: ami-0196cda9251876643
      Windows2012R2: ami-0196cda9251876643
      Windows2016: ami-04ad37d2932b886c0
      Windows2019: ami-04ad37d2932b886c0
Parameters:
  ImageIdParameters: 
        AllowedValues: 
          - Windows2019
          - Windows2016
          - Windows2012R2
          - Windows2012
          - Windows2008R2
        Default: Windows2019
        Description: "Enter Windows OS Version. Default Windows 2019"
        Type: String
Rescources:
    EC2Instance:
        Properties:
          ImageId: !FindInMap [ImageMapping, !Ref "WindowsImage", !Ref ImageIdParameters]

模板包含错误。:模板格式错误:模板的资源块中未解决的资源依赖项 [WindowsImage]

【问题讨论】:

    标签: yaml amazon-cloudformation


    【解决方案1】:

    应该只是WindowsImage,而不是!Ref "WindowsImage"

    !FindInMap [ImageMapping, WindowsImage, !Ref ImageIdParameters]
    

    或者:

    ImageId: !FindInMap
      - ImageMapping
      - WindowsImage
      - !Ref ImageIdParameters
    

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 2021-01-19
      • 1970-01-01
      • 2020-09-15
      • 2019-03-28
      • 1970-01-01
      • 2015-08-07
      • 2018-11-14
      • 2020-05-15
      相关资源
      最近更新 更多