in cloud/aws/node/generate-setup-script.py [0:0]
def replaceConstants(string, constants):
"""
Converts EC2 ImageBuilder constant references to PowerShell variable references
"""
# If the value of a constant is used as a magic value rather than a reference,
# replace it with a reference to the variable representing the constant instead
transformed = string
for key, value in constants.items():
transformed = transformed.replace(value, '${}'.format(key))
# Convert `{{ variable }}` syntax to PowerShell `$variable` syntax
# (Note that we don't bother to wrap the variable names in curly braces, since we know that none
# of the variable names contain special characters, and they're only ever interpolated as either
# part of a filesystem path surrounded by separators, or as a parameter surrounded by whitespace)
return re.sub('{{ (.+?) }}', '$\\1', transformed)