2
2
import random
3
3
import re
4
4
import string # pylint: disable=deprecated-module
5
- from typing import Any , Callable , Dict , Set
5
+ from typing import Any , Callable , Dict , Iterator , Set
6
6
7
7
from integration .config .service_names import (
8
8
APP_SYNC ,
12
12
REST_API ,
13
13
S3_EVENTS ,
14
14
SCHEDULE_EVENT ,
15
+ SNS_FILTER_POLICY_SCOPE ,
15
16
SQS ,
16
17
STATE_MACHINE_INLINE_DEFINITION ,
17
18
)
@@ -210,6 +211,17 @@ def _resource_using_s3_events(resource: Dict[str, Any]) -> bool:
210
211
return resource_type == "AWS::S3::Bucket" and properties .get ("NotificationConfiguration" )
211
212
212
213
214
+ def _get_all_event_sources (template_dict : Dict [str , Any ]) -> Iterator [Dict [str , Any ]]:
215
+ resources = template_dict .get ("Resources" , {}).values ()
216
+ for resource in resources :
217
+ for event in resource .get ("Properties" , {}).get ("Events" , {}).values ():
218
+ yield event
219
+
220
+
221
+ def _event_using_sns_filter_policy_scope (event : Dict [str , Any ]) -> bool :
222
+ return event ["Type" ] == "SNS" and "FilterPolicyScope" in event .get ("Properties" , {})
223
+
224
+
213
225
SERVICE_DETECTORS : Dict [str , Callable [[Dict [str , Any ], Set [str ]], bool ]] = {
214
226
HTTP_API : lambda template_dict , cfn_resource_types : "AWS::ApiGatewayV2::Api" in cfn_resource_types ,
215
227
REST_API : lambda template_dict , cfn_resource_types : "AWS::ApiGateway::RestApi" in cfn_resource_types ,
@@ -225,6 +237,9 @@ def _resource_using_s3_events(resource: Dict[str, Any]) -> bool:
225
237
),
226
238
LOCATION : lambda template_dict , cfn_resource_types : "AWS::Location::PlaceIndex" in cfn_resource_types ,
227
239
APP_SYNC : lambda template_dict , cfn_resource_types : "AWS::AppSync::GraphQLApi" in cfn_resource_types ,
240
+ SNS_FILTER_POLICY_SCOPE : lambda template_dict , cfn_resource_types : any (
241
+ _event_using_sns_filter_policy_scope (event ) for event in _get_all_event_sources (template_dict )
242
+ ),
228
243
}
229
244
230
245
0 commit comments