Skip to content

Commit

Permalink
add support for pre-parsed TemplateBody (fixes #609) (#610)
Browse files Browse the repository at this point in the history
Co-authored-by: Rob Brazier <git@brzr.co>
  • Loading branch information
RobBrazier and RobBrazier committed Dec 5, 2022
1 parent fe405a5 commit d43e52e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions servicecatalog_puppet/workflow/stack/provision_stack_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import re
import time
from collections import OrderedDict

import cfn_tools
import luigi
Expand Down Expand Up @@ -221,15 +222,18 @@ def run(self):
template_body = cloudformation.get_template(
StackName=self.stack_name_to_use, TemplateStage="Original"
).get("TemplateBody")
try:
existing_template = cfn_tools.load_yaml(template_body)
except Exception:
if isinstance(template_body, OrderedDict):
existing_template = template_body
else:
try:
existing_template = cfn_tools.load_json(template_body)
existing_template = cfn_tools.load_yaml(template_body)
except Exception:
raise Exception(
"Could not parse existing template as YAML or JSON"
)
try:
existing_template = cfn_tools.load_json(template_body)
except Exception:
raise Exception(
"Could not parse existing template as YAML or JSON"
)

template_to_use = cfn_tools.dump_yaml(template_to_provision)
if status in ["UPDATE_ROLLBACK_COMPLETE", "NoStack"]:
Expand Down

0 comments on commit d43e52e

Please sign in to comment.