Skip to content

Commit

Permalink
Resolve strings that are integers in Fn::Cidr
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong committed Oct 21, 2024
1 parent 6033243 commit 106090c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/cfnlint/rules/functions/Cidr.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ def check_ip_block(self, value, path):
def check_count(self, value, path):
matches = []
count_parameters = []
if isinstance(value, str):
try:
value = int(value)
except Exception: # pylint: disable=broad-exception-caught
pass
if isinstance(value, dict):
if len(value) == 1:
for index_key, index_value in value.items():
Expand Down Expand Up @@ -116,6 +121,11 @@ def check_count(self, value, path):
def check_size_mask(self, value, path):
matches = []
size_mask_parameters = []
if isinstance(value, str):
try:
value = int(value)
except Exception: # pylint: disable=broad-exception-caught
pass
if isinstance(value, dict):
if len(value) == 1:
for index_key, index_value in value.items():
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/templates/good/functions/cidr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ Resources:
- 8
- 4
- 6
- 2
- 4
- "2"
- "4"
VpcId: 'vpc-123456'
PublicSubnet1:
Type: AWS::EC2::Subnet
Expand Down

0 comments on commit 106090c

Please sign in to comment.