Skip to content
Merged
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
@@ -1,5 +1,7 @@
import yaml

from localstack.services.cloudformation.engine.validations import ValidationError


def construct_raw(_, node):
return node.value
Expand Down Expand Up @@ -60,5 +62,10 @@ def shorthand_constructor(loader: yaml.Loader, tag_suffix: str, node: yaml.Node)
yaml.add_multi_constructor("!", shorthand_constructor, customloader)


def parse_yaml(input_data: str):
return yaml.load(input_data, customloader)
def parse_yaml(input_data: str) -> dict:
parsed = yaml.load(input_data, Loader=customloader)

if not isinstance(parsed, dict):
raise ValidationError("Template format error: unsupported structure.")

return parsed
12 changes: 12 additions & 0 deletions tests/aws/services/cloudformation/api/test_stacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,18 @@ def test_stack_name_creation(self, deploy_cfn_template, snapshot, aws_client):

snapshot.match("stack_response", e.value.response)

@markers.aws.validated
def test_create_stack_url_as_template(self, snapshot, aws_client):
snapshot.add_transformer(snapshot.transform.cloudformation_api())

stack_name = f"stack-{short_uid()}"

template_url = "https://raw.githubusercontent.com/aws-cloudformation/aws-cloudformation-templates/refs/heads/main/EC2/InstanceWithCfnInit.yaml"

with pytest.raises(ClientError) as e:
aws_client.cloudformation.create_stack(StackName=stack_name, TemplateBody=template_url)
snapshot.match("stack_create_ec2", e.value)

@markers.aws.validated
@pytest.mark.parametrize("fileformat", ["yaml", "json"])
def test_get_template_using_create_stack(self, snapshot, fileformat, aws_client):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4347,5 +4347,11 @@
]
}
}
},
"tests/aws/services/cloudformation/api/test_stacks.py::TestStacksApi::test_create_stack_url_as_template": {
"recorded-date": "23-10-2025, 19:25:10",
"recorded-content": {
"stack_create_ec2": "An error occurred (ValidationError) when calling the CreateStack operation: Template format error: unsupported structure."
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"tests/aws/services/cloudformation/api/test_stacks.py::TestStacksApi::test_create_stack_url_as_template": {
"last_validated_date": "2025-10-23T19:25:10+00:00",
"durations_in_seconds": {
"setup": 0.82,
"call": 0.82,
"teardown": 0.02,
"total": 1.66
}
},
"tests/aws/services/cloudformation/api/test_stacks.py::TestStacksApi::test_failure_options_for_stack_update[False-2]": {
"last_validated_date": "2024-06-25T17:21:51+00:00"
},
Expand Down
Loading