Skip to content

CFNV2: finish URL replacements for API Gateway #13012

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

Open
wants to merge 2 commits into
base: cfn/v2/implement-no-echo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from localstack.services.cloudformation.engine.template_deployer import REGEX_OUTPUT_APIGATEWAY
from localstack.services.cloudformation.engine.v2.change_set_model import (
NodeDependsOn,
NodeIntrinsicFunction,
NodeOutput,
NodeResource,
TerminalValueCreated,
Expand Down Expand Up @@ -585,6 +586,15 @@ def _replace_url_outputs_if_required(value: str) -> str:

return value

def _replace_url_outputs_in_delta_if_required(
self, delta: PreprocEntityDelta
) -> PreprocEntityDelta:
if not is_nothing(delta.before) and isinstance(delta.before, str):
delta.before = self._replace_url_outputs_if_required(delta.before)
if not is_nothing(delta.after) and isinstance(delta.after, str):
delta.after = self._replace_url_outputs_if_required(delta.after)
return delta

def visit_terminal_value_created(
self, value: TerminalValueCreated
) -> PreprocEntityDelta[str, str]:
Expand Down Expand Up @@ -612,3 +622,17 @@ def visit_terminal_value_unchanged(
else:
value = terminal_value_unchanged.value
return PreprocEntityDelta(before=value, after=value)

def visit_node_intrinsic_function_fn_join(
self, node_intrinsic_function: NodeIntrinsicFunction
) -> PreprocEntityDelta:
delta = super().visit_node_intrinsic_function_fn_join(node_intrinsic_function)
return self._replace_url_outputs_in_delta_if_required(delta)

def visit_node_intrinsic_function_fn_sub(
self, node_intrinsic_function: NodeIntrinsicFunction
) -> PreprocEntityDelta:
delta = super().visit_node_intrinsic_function_fn_sub(node_intrinsic_function)
return self._replace_url_outputs_in_delta_if_required(delta)

# TODO: other intrinsic functions
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,6 @@ def _invoke():
assert content["url"].endswith("/post")


@skip_if_v2_provider(
"Provider",
reason="The v2 provider appears to instead return the correct url: "
"https://e1i3grfiws.execute-api.us-east-1.localhost.localstack.cloud/prod/",
)
@markers.aws.only_localstack
def test_url_output(httpserver, deploy_cfn_template):
httpserver.expect_request("").respond_with_data(b"", 200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def test_resolve_ssm(self, create_parameter, deploy_cfn_template):
topic_name = result.outputs["TopicName"]
assert topic_name == parameter_value

@skip_if_v2_provider("Resolve")
@markers.aws.validated
def test_resolve_ssm_with_version(self, create_parameter, deploy_cfn_template, aws_client):
parameter_key = f"param-key-{short_uid()}"
Expand Down
Loading