1515from typing import TYPE_CHECKING , Any , Literal , Sequence
1616
1717import boto3
18- import common
1918from botocore .exceptions import ClientError
2019
2120if TYPE_CHECKING :
5150
5251
5352UNEXPECTED = "Unexpected!"
54- # shield_THROTTLE_PERIOD: float = 0.2
55- ENABLE_RETRY_ATTEMPTS : int = 10
56- ENABLE_RETRY_SLEEP_INTERVAL : int = 10
5753RESOURCES_BY_ACCOUNT : dict = {}
5854
5955try :
@@ -644,7 +640,6 @@ def create_protection_group(shield_client: ShieldClient, params: dict, account_i
644640 account_id: AWS account id
645641 """
646642 for i in range (0 , 5 ):
647- print (i )
648643 pg_id : str = params [f"PROTECTION_GROUP_{ i } _ID" ]
649644 pg_account_id : str = params [f"PROTECTION_GROUP_{ i } _ACCOUNT_ID" ]
650645 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
657652 "APPLICATION_LOAD_BALANCER" ,
658653 "GLOBAL_ACCELERATOR" ,
659654 ] = params [f"PROTECTION_GROUP_{ i } _RESOURCE_TYPE" ]
660- print (f" pg_account_id { pg_account_id } " )
661655 pg_members : list = params [f"PROTECTION_GROUP_{ i } _MEMBERS" ]
662- print (f"pg_members{ pg_members } " )
663- print (f"i { i } " )
664656 if pg_id != "" and pg_account_id == account_id :
665657 if check_if_protection_group_exists (shield_client , pg_id ):
666658 LOGGER .info (f"Protection_Group_{ i } already exists in { account_id } " )
@@ -695,7 +687,10 @@ def check_emergency_contacts(shield_client: ShieldClient) -> bool:
695687 emergency_contacts_response : DescribeEmergencyContactSettingsResponseTypeDef = shield_client .describe_emergency_contact_settings ()
696688 api_call_details = {"API_Call" : "shield:DescribeEmergencyContactSettings" , "API_Response" : emergency_contacts_response }
697689 LOGGER .info (api_call_details )
698- return True
690+ if len (emergency_contacts_response ) > 0 :
691+ return True
692+ else :
693+ return False
699694 except shield_client .exceptions .ResourceNotFoundException :
700695 return False
701696
@@ -707,7 +702,6 @@ def enable_proactive_engagement(shield_client: ShieldClient, params: dict) -> No
707702 shield_client: shield client
708703 params: environment variables
709704 """
710- print (f"Before IF SHIELD_ENABLE_PROACTIVE_ENGAGEMENT is set to { params ['SHIELD_ENABLE_PROACTIVE_ENGAGEMENT' ]} " )
711705 if params ["SHIELD_ENABLE_PROACTIVE_ENGAGEMENT" ] == "true" :
712706 if check_proactive_engagement_enabled (shield_client , params ):
713707 update_emergency_contacts (shield_client , params )
0 commit comments