Reputation: 23
I am attempting to build my first larger Cloudformation template; however, I keep running into issues with the Image selection process as it does not like my current configuration.
I am trying to have a user select a Windows OS version, which would then have the CFN Template select the AMI that matches this Windows version.
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]
Template contains errors.: Template format error: Unresolved resource dependencies [WindowsImage] in the Resources block of the template
Upvotes: 2
Views: 473
Reputation: 43651
Should be simply WindowsImage
, not !Ref "WindowsImage"
:
!FindInMap [ImageMapping, WindowsImage, !Ref ImageIdParameters]
Or:
ImageId: !FindInMap
- ImageMapping
- WindowsImage
- !Ref ImageIdParameters
Upvotes: 1