U bf @sPddlZddlmZddZedkrLeZded<ded<d ed <eeddS) N)datetimec Csttdd|d}|d}|d}tjd|d}|jdd d }|j|d |d d d }|j|d |d d d }tjddd}|j|d} | dd} dddddg} d} g} | D](}| D]}|d|kr| |dqq| D]}zttdd|tjd||d}ttdd|dttdd|d|j |dd |j |dd ttdd!WqWqt k r}z t|W5d}~XYqXqdS)"Nz%m/%d/%Y, %H:%M:%Sz$ switch_off_primary_controls Invoked AWS_REGIONAWS_PRIMARY_REGIONAPPsecretsmanager) region_namez dtcc-cluster)SecretId SecretString-z -arc-controlz-inbound-gateway-zroute53-recovery-control-configz us-west-2) ClusterArnClusterClusterEndpoints us-east-1z eu-west-1zap-northeast-1zap-southeast-2rRegionEndpointz$ route 53 recover cluster endpoint: zroute53-recovery-cluster)r endpoint_urlz updating control: z to OffZOff)RoutingControlArnRoutingControlStatez successfully updated controls) printrnowstrftimeboto3clientget_secret_valuedescribe_clusterappendZupdate_routing_control_state Exception)eventcontext aws_regionZprimary_regionappr dtcc_clusterZapp_primary_controlZ#app_inbound_gateway_primary_controlcluster endpointsregionscountersorted_endpointsregionendpointer*l/Users/behebika/dev/DTCC/app-rotation/infrastructure/apps/common/rotation/src/switch_off_primary_controls.pyswitch_off_primary_controlss<    r,__main__rrrztrade-matchingr)rrr,__name__dictrr*r*r*r+s (