Skip to content

Commit 07f06d0

Browse files
committed
Add a to_change_action for getting the change action
1 parent ddae422 commit 07f06d0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

localstack-core/localstack/services/cloudformation/engine/v2/change_set_model.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from typing_extensions import TypeVar
99

10+
from localstack.aws.api.cloudformation import ChangeAction
1011
from localstack.utils.strings import camel_to_snake_case
1112

1213
T = TypeVar("T")
@@ -109,6 +110,14 @@ class ChangeType(enum.Enum):
109110
def __str__(self):
110111
return self.value
111112

113+
def to_change_action(self) -> ChangeAction:
114+
# Convert this change type into the change action used throughout the CFn API
115+
return {
116+
ChangeType.CREATED: ChangeAction.Add,
117+
ChangeType.MODIFIED: ChangeAction.Modify,
118+
ChangeType.REMOVED: ChangeAction.Remove,
119+
}.get(self, ChangeAction.Add)
120+
112121

113122
class ChangeSetEntity(abc.ABC):
114123
scope: Final[Scope]

localstack-core/localstack/services/cloudformation/engine/v2/change_set_model_executor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,8 @@ def visit_node_resource(
180180
try:
181181
delta = super().visit_node_resource(node_resource=node_resource)
182182
except Exception as e:
183-
# TODO: change action may not match the change type
184183
self._process_event(
185-
ChangeAction.Modify,
184+
node_resource.change_type.to_change_action(),
186185
node_resource.name,
187186
OperationStatus.FAILED,
188187
reason=str(e),

0 commit comments

Comments
 (0)