Skip to content

Commit

Permalink
Merge branch 'main' into create-pull-request/maintenance-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
kddejong authored Dec 13, 2024
2 parents 153b05a + f920591 commit fda0567
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,23 @@
}
},
"Memory": {
"enum": [
"0.5 GB",
"1 GB",
"2 GB",
"512",
"1024",
"2048"
]
"else": {
"pattern": "^(0.5|1|2)\\s*(?i)GB$"
},
"if": {
"pattern": "^\\d+$",
"type": [
"integer",
"string"
]
},
"then": {
"enum": [
512,
1024,
2048
]
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/cfnlint/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
REGEX_DYN_REF_SSM_SECURE = re.compile(
r"^.*{{resolve:ssm-secure:[a-zA-Z0-9_\.\-/]+(:\d+)?}}.*$"
)
REGEX_SUB_PARAMETERS = re.compile(r"\${([^!].*?)}")
REGEX_SUB_PARAMETERS = re.compile(r"\${\s*([^!\s].*?)\s*}")

FUNCTIONS = frozenset(
[
Expand Down
12 changes: 12 additions & 0 deletions test/unit/rules/functions/test_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ def context(cfn):
{"type": "string"},
[],
),
(
"Valid Fn::Sub with a space and escape char",
{"Fn::Sub": "${ !Foo }"},
{"type": "string"},
[],
),
(
"Valid Fn::Sub with a space and no escape char",
{"Fn::Sub": "${ AWS::AccountId }"},
{"type": "string"},
[],
),
(
"Invalid Fn::Sub with a too to many elements",
{"Fn::Sub": ["${foo}", {"foo": "bar"}, {}]},
Expand Down

0 comments on commit fda0567

Please sign in to comment.