in source/cdk_solution_helper_py/helpers_cdk/aws_solutions/cdk/synthesizers.py [0:0]
def synthesize(self, session: ISynthesisSession):
# when called with `cdk deploy` this outputs to cdk.out
# when called from python directly, this outputs to a temporary directory
result = DefaultStackSynthesizer.synthesize(self, session)
asset_path_regional = self._stack.node.try_get_context(
"SOLUTIONS_ASSETS_REGIONAL"
)
asset_path_global = self._stack.node.try_get_context("SOLUTIONS_ASSETS_GLOBAL")
logger.info(
f"solutions parameter substitution in {session.assembly.outdir} started"
)
for template in self._template_names(session):
logger.info(f"substutiting parameters in {str(template)}")
with FileInput(template, inplace=True) as template_lines:
for line in template_lines:
# handle all template subsitutions in the line
for match in SolutionStackSubstitions.substitution_re.findall(line):
placeholder = match.replace("%", "")
replacement = self._stack.node.try_get_context(placeholder)
if not replacement:
raise ValueError(
f"Please provide a parameter substitution for {placeholder} via environment variable or CDK context"
)
line = line.replace(match, replacement)
# print the (now substituted) line in the context of template_lines
print(line, end="")
logger.info(f"substituting parameters in {str(template)} completed")
logger.info("solutions parameter substitution completed")
# do not perform solution resource/ template cleanup if asset paths not passed
if not asset_path_global or not asset_path_regional:
return
logger.info(
f"solutions template customization in {session.assembly.outdir} started"
)
for template in self._templates(session):
template.patch_lambda()
template.patch_nested()
template.delete_bootstrap_parameters()
template.delete_cdk_helpers()
template.save(
asset_path_global=asset_path_global,
asset_path_regional=asset_path_regional,
)
logger.info("solutions template customization completed")
return result