Skip to content

Commit a0208dd

Browse files
authored
chore: Add integration test service detector for SNS FilterPolicyScope (#3015)
1 parent 6e197db commit a0208dd

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

integration/config/service_names.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
SNS = "SNS"
2323
SQS = "SQS"
2424
CUSTOM_DOMAIN = "CustomDomain"
25-
ARM = "ARM"
2625
EFS = "EFS"
2726
S3_EVENTS = "S3Events"
2827
SELF_MANAGED_KAFKA = "SelfManagedKafka"
@@ -36,3 +35,4 @@
3635
EPHEMERAL_STORAGE = "EphemeralStorage"
3736
API_KEY = "ApiKey"
3837
APP_SYNC = "AppSync"
38+
SNS_FILTER_POLICY_SCOPE = "SnsFilterPolicyScope"

integration/helpers/resource.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import random
33
import re
44
import string # pylint: disable=deprecated-module
5-
from typing import Any, Callable, Dict, Set
5+
from typing import Any, Callable, Dict, Iterator, Set
66

77
from integration.config.service_names import (
88
APP_SYNC,
@@ -12,6 +12,7 @@
1212
REST_API,
1313
S3_EVENTS,
1414
SCHEDULE_EVENT,
15+
SNS_FILTER_POLICY_SCOPE,
1516
SQS,
1617
STATE_MACHINE_INLINE_DEFINITION,
1718
)
@@ -210,6 +211,17 @@ def _resource_using_s3_events(resource: Dict[str, Any]) -> bool:
210211
return resource_type == "AWS::S3::Bucket" and properties.get("NotificationConfiguration")
211212

212213

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+
213225
SERVICE_DETECTORS: Dict[str, Callable[[Dict[str, Any], Set[str]], bool]] = {
214226
HTTP_API: lambda template_dict, cfn_resource_types: "AWS::ApiGatewayV2::Api" in cfn_resource_types,
215227
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:
225237
),
226238
LOCATION: lambda template_dict, cfn_resource_types: "AWS::Location::PlaceIndex" in cfn_resource_types,
227239
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+
),
228243
}
229244

230245

0 commit comments

Comments
 (0)