@@ -110,3 +110,33 @@ def test_inject_raises_when_no_functions(tmp_path: Path) -> None:
110110
111111 with pytest .raises (SystemExit ):
112112 inject_execution_role .inject (template , ROLE_ARN )
113+
114+
115+ def test_plugin_logging_survives_execution_role_injection (tmp_path : Path ) -> None :
116+ source = Path (__file__ ).resolve ().parents [1 ] / "template_plugin.yaml"
117+ original = yaml .safe_load (source .read_text ())
118+ expected_functions = {
119+ name : resource
120+ for name , resource in original ["Resources" ].items ()
121+ if resource .get ("Type" ) == "AWS::Serverless::Function"
122+ and "DurableConfig" in resource .get ("Properties" , {})
123+ }
124+ assert expected_functions
125+ template = _write (tmp_path , original )
126+
127+ assert inject_execution_role .inject (template , ROLE_ARN ) == len (expected_functions )
128+ actual = yaml .safe_load (Path (template ).read_text ())
129+ global_logging = actual ["Globals" ]["Function" ].get ("LoggingConfig" , {})
130+ for name , original_resource in expected_functions .items ():
131+ resource = actual ["Resources" ][name ]
132+ properties = resource ["Properties" ]
133+ effective_logging = {** global_logging , ** properties .get ("LoggingConfig" , {})}
134+ assert effective_logging .get ("LogFormat" , "Text" ) == "JSON" , (
135+ f"{ name } : Lambda durable functions require JSON logs"
136+ )
137+ assert properties ["Role" ] == ROLE_ARN
138+ assert (
139+ properties ["DurableConfig" ]
140+ == original_resource ["Properties" ]["DurableConfig" ]
141+ )
142+ assert resource ["TestingMetadata" ] == original_resource ["TestingMetadata" ]
0 commit comments