Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion aws_parsecf/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ def fn_sub(self, value):
"""
>>> from aws_parsecf.parser import Parser

>>> root = {'Parameters': {'Who': {'Type': 'String', 'Default': 'world'},
... 'When': {'Type': 'String', 'Default': 'NOW'}},
... 'Fn::Sub': 'hello-${Who} ${When}'}
>>> Functions(Parser(root, 'us-east-1'),
... root,
... 'us-east-1'
... ).fn_sub('hello-${Who} ${When}')
'hello-world NOW'

>>> root = {'Fn::Sub': ['hello-${Who} ${When}', {'Who': 'world', 'When': 'NOW'}]}
>>> Functions(Parser(root, 'us-east-1'),
... root,
Expand Down Expand Up @@ -385,7 +394,7 @@ def _find_att(self, current, key):
return result
raise KeyError(key)

SUB_VARIABLE_PATTERN = re.compile(r"\${(.+)}")
SUB_VARIABLE_PATTERN = re.compile(r"\${(.+?)}")
def _sub_variable(self, match):
variable = match.group(1)
if variable.startswith('!'):
Expand Down