15
15
from typing import TYPE_CHECKING , Any , Literal , Sequence
16
16
17
17
import boto3
18
- import common
19
18
from botocore .exceptions import ClientError
20
19
21
20
if TYPE_CHECKING :
51
50
52
51
53
52
UNEXPECTED = "Unexpected!"
54
- # shield_THROTTLE_PERIOD: float = 0.2
55
- ENABLE_RETRY_ATTEMPTS : int = 10
56
- ENABLE_RETRY_SLEEP_INTERVAL : int = 10
57
53
RESOURCES_BY_ACCOUNT : dict = {}
58
54
59
55
try :
@@ -644,7 +640,6 @@ def create_protection_group(shield_client: ShieldClient, params: dict, account_i
644
640
account_id: AWS account id
645
641
"""
646
642
for i in range (0 , 5 ):
647
- print (i )
648
643
pg_id : str = params [f"PROTECTION_GROUP_{ i } _ID" ]
649
644
pg_account_id : str = params [f"PROTECTION_GROUP_{ i } _ACCOUNT_ID" ]
650
645
pg_aggregation : Literal ["SUM" , "MEAN" , "MAX" ] = params [f"PROTECTION_GROUP_{ i } _AGGREGATION" ]
@@ -657,10 +652,7 @@ def create_protection_group(shield_client: ShieldClient, params: dict, account_i
657
652
"APPLICATION_LOAD_BALANCER" ,
658
653
"GLOBAL_ACCELERATOR" ,
659
654
] = params [f"PROTECTION_GROUP_{ i } _RESOURCE_TYPE" ]
660
- print (f" pg_account_id { pg_account_id } " )
661
655
pg_members : list = params [f"PROTECTION_GROUP_{ i } _MEMBERS" ]
662
- print (f"pg_members{ pg_members } " )
663
- print (f"i { i } " )
664
656
if pg_id != "" and pg_account_id == account_id :
665
657
if check_if_protection_group_exists (shield_client , pg_id ):
666
658
LOGGER .info (f"Protection_Group_{ i } already exists in { account_id } " )
@@ -695,7 +687,10 @@ def check_emergency_contacts(shield_client: ShieldClient) -> bool:
695
687
emergency_contacts_response : DescribeEmergencyContactSettingsResponseTypeDef = shield_client .describe_emergency_contact_settings ()
696
688
api_call_details = {"API_Call" : "shield:DescribeEmergencyContactSettings" , "API_Response" : emergency_contacts_response }
697
689
LOGGER .info (api_call_details )
698
- return True
690
+ if len (emergency_contacts_response ) > 0 :
691
+ return True
692
+ else :
693
+ return False
699
694
except shield_client .exceptions .ResourceNotFoundException :
700
695
return False
701
696
@@ -707,7 +702,6 @@ def enable_proactive_engagement(shield_client: ShieldClient, params: dict) -> No
707
702
shield_client: shield client
708
703
params: environment variables
709
704
"""
710
- print (f"Before IF SHIELD_ENABLE_PROACTIVE_ENGAGEMENT is set to { params ['SHIELD_ENABLE_PROACTIVE_ENGAGEMENT' ]} " )
711
705
if params ["SHIELD_ENABLE_PROACTIVE_ENGAGEMENT" ] == "true" :
712
706
if check_proactive_engagement_enabled (shield_client , params ):
713
707
update_emergency_contacts (shield_client , params )
0 commit comments