Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CloudFormation v2 Engine: Base Support for AWS::NoValue and Migration to Nothing Types #12668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 2, 2025

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
NodeIntrinsicFunction,
NodeProperty,
NodeResource,
Nothing,
PropertiesKey,
is_nothing,
)
from localstack.services.cloudformation.engine.v2.change_set_model_preproc import (
ChangeSetModelPreproc,
Expand Down Expand Up @@ -53,8 +55,8 @@ def visit_node_intrinsic_function_fn_get_att(
if isinstance(after_argument, str):
after_argument = after_argument.split(".")

before = None
if before_argument:
before = Nothing
if not is_nothing(before_argument):
before_logical_name_of_resource = before_argument[0]
before_attribute_name = before_argument[1]
before_node_resource = self._get_node_resource_for(
Expand All @@ -72,8 +74,8 @@ def visit_node_intrinsic_function_fn_get_att(
property_name=before_attribute_name,
)

after = None
if after_argument:
after = Nothing
if not is_nothing(after_argument):
after_logical_name_of_resource = after_argument[0]
after_attribute_name = after_argument[1]
after_node_resource = self._get_node_resource_for(
Expand Down Expand Up @@ -154,7 +156,7 @@ def _describe_resource_change(
if before == after:
# unchanged: nothing to do.
return
if before is not None and after is not None:
if not is_nothing(before) and not is_nothing(after):
# Case: change on same type.
if before.resource_type == after.resource_type:
# Register a Modified if changed.
Expand Down Expand Up @@ -184,7 +186,7 @@ def _describe_resource_change(
before_properties=None,
after_properties=after.properties,
)
elif before is not None:
elif not is_nothing(before):
# Case: removal
self._register_resource_change(
logical_id=name,
Expand All @@ -193,7 +195,7 @@ def _describe_resource_change(
before_properties=before.properties,
after_properties=None,
)
elif after is not None:
elif not is_nothing(after):
# Case: addition
self._register_resource_change(
logical_id=name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
NodeOutput,
NodeParameter,
NodeResource,
is_nothing,
)
from localstack.services.cloudformation.engine.v2.change_set_model_preproc import (
ChangeSetModelPreproc,
Expand Down Expand Up @@ -113,13 +114,13 @@ def visit_node_resource(
# There are no updates for this resource; iff the resource was previously
# deployed, then the resolved details are copied in the current state for
# references or other downstream operations.
if before is not None:
if not is_nothing(before):
before_logical_id = delta.before.logical_id
before_resource = self._before_resolved_resources.get(before_logical_id, dict())
self.resources[before_logical_id] = before_resource

# Update the latest version of this resource for downstream references.
if after is not None:
if not is_nothing(after):
after_logical_id = after.logical_id
after_physical_id: str = self._after_resource_physical_id(
resource_logical_id=after_logical_id
Expand All @@ -132,7 +133,7 @@ def visit_node_output(
) -> PreprocEntityDelta[PreprocOutput, PreprocOutput]:
delta = super().visit_node_output(node_output=node_output)
after = delta.after
if after is None or (isinstance(after, PreprocOutput) and after.condition is False):
if is_nothing(after) or (isinstance(after, PreprocOutput) and after.condition is False):
return delta
self.outputs[delta.after.name] = delta.after.value
return delta
Expand All @@ -142,7 +143,7 @@ def _execute_resource_change(
) -> None:
# Changes are to be made about this resource.
# TODO: this logic is a POC and should be revised.
if before is not None and after is not None:
if not is_nothing(before) and not is_nothing(after):
# Case: change on same type.
if before.resource_type == after.resource_type:
# Register a Modified if changed.
Expand Down Expand Up @@ -177,7 +178,7 @@ def _execute_resource_change(
before_properties=None,
after_properties=after.properties,
)
elif before is not None:
elif not is_nothing(before):
# Case: removal
# XXX hacky, stick the previous resources' properties into the payload
# XXX hacky, stick the previous resources' properties into the payload
Expand All @@ -190,7 +191,7 @@ def _execute_resource_change(
before_properties=before_properties,
after_properties=None,
)
elif after is not None:
elif not is_nothing(after):
# Case: addition
self._execute_resource_action(
action=ChangeAction.Add,
Expand Down
Loading
Loading