8000 Update stack template and template body after change set completion · localstack/localstack@7572bc8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7572bc8

Browse files
committed
Update stack template and template body after change set completion
Because we were not updating the stack template, when we tried to destroy the stack we would try to delete resources that no longer existed. Now we don't.
1 parent aac4219 commit 7572bc8

File tree

1 file changed

+8
-5
lines changed
  • localstack-core/localstack/services/cloudformation/v2

1 file changed

+8
-5
lines changed

localstack-core/localstack/services/cloudformation/v2/provider.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ def create_change_set(
153153
# on a CREATE an empty Stack should be generated if we didn't find an active one
154154
if not active_stack_candidates and change_set_type == ChangeSetType.CREATE:
155155
stack = Stack(
156-
context.account_id,
157-
context.region,
158-
request,
159-
structured_template,
156+
account_id=context.account_id,
157+
region_name=context.region,
158+
request_payload=request,
159+
template=structured_template,
160160
template_body=template_body,
161161
)
162162
state.stacks_v2[stack.stack_id] = stack
@@ -218,7 +218,7 @@ def create_change_set(
218218
after_template = structured_template
219219

220220
# create change set for the stack and apply changes
221-
change_set = ChangeSet(stack, request)
221+
change_set = ChangeSet(stack, request, template=after_template)
222222

223223
# only set parameters for the changeset, then switch to stack on execute_change_set
224224
change_set.populate_update_graph(
@@ -287,6 +287,9 @@ def _run(*args):
287287
change_set.stack.resolved_resources = result.resources
288288
change_set.stack.resolved_parameters = result.parameters
289289
change_set.stack.resolved_outputs = result.outputs
290+
# if the deployment succeeded, update the stack's template representation to that
291+
# which was just deployed
292+
change_set.stack.template = change_set.template
290293
except Exception as e:
291294
LOG.error(
292295
"Execute change set failed: %s", e, exc_info=LOG.isEnabledFor(logging.WARNING)

0 commit comments

Comments
 (0)
0