in aws/hhvm1/lambdas/health_check.py [0:0]
def lambda_handler(event, context=None):
if skip_ec2(event):
# Nothing to check if this is a test run with no EC2 -- quit (and don't
# repeat).
return False
events = all_execution_events(event['execution'])
# Quit (and don't repeat) if we've reached the end state.
for e in events:
if e.get('stateEnteredEventDetails', {}).get('name') == event['endState']:
return False
# The actual health check: Find any activities that are scheduled but not
# started and make sure there's a worker ready for each.
ec2 = boto3.client('ec2')
for activity_class in get_pending_activities(events):
activity = activity_class(event)
if activity.needs_ec2_worker():
ec2.run_instances(**activity.ec2_params())
# Wait and repeat.
return True