@@ -18,14 +18,12 @@ def config() -> conftest.LambdaConfig:
1818
1919def test_basic_lambda_logs_visible (execute_lambda : conftest .InfrastructureOutput , config : conftest .LambdaConfig ):
2020 # GIVEN
21- lambda_arn = execute_lambda .get_lambda_arn ( name = "basichandlerarn" )
21+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "basichandlerarn" )
2222 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
2323 cw_client = boto3 .client ("logs" )
2424
2525 # WHEN
26- filtered_logs = helpers .get_logs (
27- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
28- )
26+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
2927
3028 # THEN
3129 assert any (
@@ -39,14 +37,12 @@ def test_basic_lambda_no_debug_logs_visible(
3937 execute_lambda : conftest .InfrastructureOutput , config : conftest .LambdaConfig
4038):
4139 # GIVEN
42- lambda_arn = execute_lambda .get_lambda_arn ( name = "basichandlerarn" )
40+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "basichandlerarn" )
4341 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
4442 cw_client = boto3 .client ("logs" )
4543
4644 # WHEN
47- filtered_logs = helpers .get_logs (
48- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
49- )
45+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
5046
5147 # THEN
5248 assert not any (
@@ -65,14 +61,12 @@ def test_basic_lambda_contextual_data_logged(execute_lambda: conftest.Infrastruc
6561 "cold_start" ,
6662 )
6763
68- lambda_arn = execute_lambda .get_lambda_arn ( name = "basichandlerarn" )
64+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "basichandlerarn" )
6965 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
7066 cw_client = boto3 .client ("logs" )
7167
7268 # WHEN
73- filtered_logs = helpers .get_logs (
74- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
75- )
69+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
7670
7771 # THEN
7872 assert all (keys in logs .dict (exclude_unset = True ) for logs in filtered_logs for keys in required_keys )
@@ -82,14 +76,12 @@ def test_basic_lambda_additional_key_persistence_basic_lambda(
8276 execute_lambda : conftest .InfrastructureOutput , config : conftest .LambdaConfig
8377):
8478 # GIVEN
85- lambda_arn = execute_lambda .get_lambda_arn ( name = "basichandlerarn" )
79+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "basichandlerarn" )
8680 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
8781 cw_client = boto3 .client ("logs" )
8882
8983 # WHEN
90- filtered_logs = helpers .get_logs (
91- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
92- )
84+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
9385
9486 # THEN
9587 assert any (
@@ -103,14 +95,12 @@ def test_basic_lambda_additional_key_persistence_basic_lambda(
10395def test_basic_lambda_empty_event_logged (execute_lambda : conftest .InfrastructureOutput ):
10496
10597 # GIVEN
106- lambda_arn = execute_lambda .get_lambda_arn ( name = "basichandlerarn" )
98+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "basichandlerarn" )
10799 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
108100 cw_client = boto3 .client ("logs" )
109101
110102 # WHEN
111- filtered_logs = helpers .get_logs (
112- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
113- )
103+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
114104
115105 # THEN
116106 assert any (log .message == {} for log in filtered_logs )
@@ -127,14 +117,12 @@ def test_no_context_lambda_contextual_data_not_logged(execute_lambda: conftest.I
127117 "cold_start" ,
128118 )
129119
130- lambda_arn = execute_lambda .get_lambda_arn ( name = "nocontexthandlerarn" )
120+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "nocontexthandlerarn" )
131121 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
132122 cw_client = boto3 .client ("logs" )
133123
134124 # WHEN
135- filtered_logs = helpers .get_logs (
136- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
137- )
125+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
138126
139127 # THEN
140128 assert not any (keys in logs .dict (exclude_unset = True ) for logs in filtered_logs for keys in required_missing_keys )
@@ -143,14 +131,12 @@ def test_no_context_lambda_contextual_data_not_logged(execute_lambda: conftest.I
143131def test_no_context_lambda_event_not_logged (execute_lambda : conftest .InfrastructureOutput ):
144132
145133 # GIVEN
146- lambda_arn = execute_lambda .get_lambda_arn ( name = "nocontexthandlerarn" )
134+ lambda_name = execute_lambda .get_lambda_function_name ( cf_output_name = "nocontexthandlerarn" )
147135 timestamp = execute_lambda .get_lambda_execution_time_timestamp ()
148136 cw_client = boto3 .client ("logs" )
149137
150138 # WHEN
151- filtered_logs = helpers .get_logs (
152- lambda_function_name = lambda_arn .split (":" )[- 1 ], start_time = timestamp , log_client = cw_client
153- )
139+ filtered_logs = helpers .get_logs (lambda_function_name = lambda_name , start_time = timestamp , log_client = cw_client )
154140
155141 # THEN
156142 assert not any (log .message == {} for log in filtered_logs )
0 commit comments