I want to write two functions in a single AWS Lambda function. currently, Lambda triggers the function using the handler in case I have two functions in my code then how to change it so that the Lambda handler can execute both the functions.
I have found this. However, it is using if statement. In my scenario I will have to run both the functions one after the other and also pass the output of 1st function to the 2nd function. Thanks How to have more than one handler in AWS Lambda Function?
Here is the sample code:
import boto3' import json' from datetime
import datetime REGION = 'us-east-1'
emrclient = boto3.client('emr', region_name=REGION)
def lambda_handler(event, context):
EMRS = emrclient.list_clusters( ClusterStates = ['STARTING', 'RUNNING', 'WAITING', 'TERMINATING'] )
clusters = EMRS["Clusters"]
for cluster in clusters :
ID = cluster.get("Id")
EMRid = emrclient.list_instance_groups( ClusterId = str("ID") )
print(EMRid)