From ccb4d2967d988878e08503d20ec494054c2d4cfc Mon Sep 17 00:00:00 2001 From: kian Date: Sun, 15 Dec 2019 22:57:05 -0500 Subject: [PATCH] Add detected changes to new template to preserve source template Resource dict integrity. --- src/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.py b/src/main.py index 77029ca..f57d017 100644 --- a/src/main.py +++ b/src/main.py @@ -20,14 +20,17 @@ def recursiveFindReplaceText(obj, text, replace): def replaceWaitConditionLogicalIds(template, paramHash): + newTemplate = template changes = [] for logicalId, resource in template['Resources'].items(): if resource['Type'] in ["AWS::CloudFormation::WaitConditionHandle", "AWS::CloudFormation::WaitCondition"] and not logicalId.endswith(paramHash): newId = logicalId+paramHash - template['Resources'][newId] = template['Resources'].pop(logicalId) changes.append((logicalId, newId)) - return template, changes + for change in changes: + newTemplate['Resources'][change[1]] = template['Resources'].pop(change[0]) + + return newTemplate, changes def handler(event, context):