Skip to content

Commit e517a00

Browse files
authored
Fix an issue with W1011 to allow integers in the FindInMap (#3272)
1 parent 600ee1f commit e517a00

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/cfnlint/rules/functions/FindInMapKeys.py

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def check_keys(self, map_name, keys, mappings, tree, cfn):
2828
mapping = mappings.get(map_name)
2929
if mapping:
3030
if isinstance(first_key, (str, int)):
31+
first_key = str(first_key)
3132
if isinstance(map_name, (str)):
3233
if mapping.get(first_key) is None:
3334
message = 'FindInMap first key "{0}" doesn\'t exist in map "{1}" at {3}'
@@ -44,6 +45,7 @@ def check_keys(self, map_name, keys, mappings, tree, cfn):
4445
)
4546
if mapping.get(first_key):
4647
# Don't double error if they first key doesn't exist
48+
second_key = str(second_key)
4749
if mapping.get(first_key, {}).get(second_key) is None:
4850
message = 'FindInMap second key "{0}" doesn\'t exist in map "{1}" under "{2}" at {3}'
4951
matches.append(

test/fixtures/templates/good/functions/findinmap_keys.yaml

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ Mappings:
44
CertificateMap:
55
us-east-1:
66
Arn: arn:aws:acm:us-east-1:<account>:certificate/<id>
7-
2:
7+
"2":
88
Arn: "" # Empty string is a valid value
9+
key:
10+
3: "" # Empty string is a valid value
911
Resources:
1012
AppAlbListener:
1113
Type: AWS::ElasticLoadBalancingV2::Listener
@@ -32,3 +34,9 @@ Resources:
3234
Certificates:
3335
- CertificateArn: # Doesn't fail with integer
3436
Fn::FindInMap: [!Ref 'AWS::Region', 2, id]
37+
AppAlbListener4:
38+
Type: AWS::ElasticLoadBalancingV2::Listener
39+
Properties:
40+
Certificates:
41+
- CertificateArn: # Doesn't fail with integer
42+
Fn::FindInMap: [!Ref 'AWS::Region', key, 3]

0 commit comments

Comments
 (0)