in scripts/testConnection.py [0:0]
def lambda_handler(event, context):
source_endpoint = event['ResourceProperties']['SourceArn']
target_endpoint = event['ResourceProperties']['TargetArn']
replication_inst = event['ResourceProperties']['ReplicationInstanceArn']
if 'Create' or 'Update' in event['RequestType']:
print ('This is a %s event' %(event['RequestType']))
print('Checking connection for Source .....')
source_result = check_connection(source_endpoint,replication_inst)
print('Source result was %s' %(source_result))
if 'success' in source_result:
print('Proceeding to check connection for Target ....')
target_result = check_connection(target_endpoint,replication_inst)
print('Target result was %s' %(target_result))
if 'success' in target_result:
cfnresponse.send(event, context, cfnresponse.SUCCESS, {}, '')
else:
print('Target connection failed')
cfnresponse.send(event, context, cfnresponse.FAILED, {}, '')
else:
print('Source connection failed')
cfnresponse.send(event, context, cfnresponse.FAILED, {}, '')
else:
print('Delete event nothing will be done')
cfnresponse.send(event, context, cfnresponse.FAILED, {}, '')