• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

localstack / localstack / 20357994067

18 Dec 2025 10:01PM UTC coverage: 86.913% (-0.02%) from 86.929%
20357994067

push

github

web-flow
Fix CloudWatch model annotation (#13545)

1 of 1 new or added line in 1 file covered. (100.0%)

1391 existing lines in 33 files now uncovered.

70000 of 80540 relevant lines covered (86.91%)

1.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/localstack-core/localstack/services/cloudformation/engine/template_preparer.py
1
import json
2✔
2
import logging
2✔
3

4
from localstack.services.cloudformation.engine import yaml_parser
2✔
5
from localstack.services.cloudformation.engine.transformers import (
2✔
6
    apply_global_transformations,
7
    apply_intrinsic_transformations,
8
)
9
from localstack.services.cloudformation.engine.validations import ValidationError
2✔
10
from localstack.utils.json import clone_safe
2✔
11

12
LOG = logging.getLogger(__name__)
2✔
13

14

15
def parse_template(template: str) -> dict:
2✔
16
    try:
2✔
17
        return json.loads(template)
2✔
18
    except Exception:
2✔
19
        try:
2✔
20
            return clone_safe(yaml_parser.parse_yaml(template))
2✔
21
        except ValidationError:
2✔
22
            # The error is handled in the yaml parsing helper
23
            raise
2✔
24
        except Exception:
2✔
25
            # TODO: present the user with a better error message including error location
26
            raise ValidationError("Template format error: YAML not well-formed.")
2✔
27

28

29
def template_to_json(template: str) -> str:
2✔
30
    template = parse_template(template)
2✔
31
    return json.dumps(template)
2✔
32

33

34
# TODO: consider moving to transformers.py as well
35
def transform_template(
2✔
36
    account_id: str,
37
    region_name: str,
38
    template: dict,
39
    stack_name: str,
40
    resources: dict,
41
    mappings: dict,
42
    conditions: dict[str, bool],
43
    resolved_parameters: dict,
44
) -> dict:
UNCOV
45
    proccesed_template = dict(template)
1✔
46

47
    # apply 'Fn::Transform' intrinsic functions (note: needs to be applied before global
48
    #  transforms below, as some utils - incl samtransformer - expect them to be resolved already)
UNCOV
49
    proccesed_template = apply_intrinsic_transformations(
1✔
50
        account_id,
51
        region_name,
52
        proccesed_template,
53
        stack_name,
54
        resources,
55
        mappings,
56
        conditions,
57
        resolved_parameters,
58
    )
59

60
    # apply global transforms
UNCOV
61
    proccesed_template = apply_global_transformations(
1✔
62
        account_id,
63
        region_name,
64
        proccesed_template,
65
        stack_name,
66
        resources,
67
        mappings,
68
        conditions,
69
        resolved_parameters,
70
    )
71

UNCOV
72
    return proccesed_template
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc