You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cfn-lint is not validating the FindInMap function for values under the Mappings section in RegionMap. In the example below, an invalid reference like 'HVM150' should throw an error since it is not defined in either the east or west regions.
Sample Yaml file:
CloudFormation Lint Version
1.16.1
What operating system are you using?
Mac
Describe the bug
cfn-lint is not validating the FindInMap function for values under the Mappings section in RegionMap. In the example below, an invalid reference like 'HVM150' should throw an error since it is not defined in either the east or west regions.
Sample Yaml file:
Mappings:
RegionMap:
us-east-1:
HVM64: "ami-0ff8a91507f77f867"
HVMG2: "ami-0a584ac55a7631c0c"
us-west-1:
HVM64: "ami-0bdb828fd58c52235"
HVMG2: "ami-066ee5fd4a9ef77f1"
Resources:
myEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !FindInMap
- RegionMap
- !Ref 'AWS::Region'
- HVM150
InstanceType: t2.micro
Expected behavior
Validation should work similarly to non-RegionMap mappings.
Example of working validation yaml
Mappings:
InstanceMap:
Small:
"InstanceType12": "t2.micro"
"KeyName": "my-key-pair-small"
Resources:
MyEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: "ami-0ff8a91507f77f867"
InstanceType:
Fn::FindInMap:
- InstanceMap
- Small
- "InstanceType12"
Reproduction template
AWSTemplateFormatVersion: '2010-09-09'
Description: AWS CloudFormation Template with FindInMap for non-region section
Mappings:
RegionMap:
us-east-1:
HVM64: "ami-0ff8a91507f77f867"
HVMG2: "ami-0a584ac55a7631c0c"
us-west-1:
HVM64: "ami-0bdb828fd58c52235"
HVMG2: "ami-066ee5fd4a9ef77f1"
Resources:
myEC2Instance:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !FindInMap
- RegionMap
- !Ref 'AWS::Region'
- HVM150
InstanceType: t2.micro
The text was updated successfully, but these errors were encountered: