def lambda_info(aws_access_key, aws_secret_key, aws_security_token, job_id, arguments): lambdas = get_aws_lambda(os.getenv("AWS_ACCESS_KEY_ID"), os.getenv("AWS_SECRET_ACCESS_KEY")) data = { "accessKey": aws_access_key, "secretKey": aws_secret_key, "sessionToken": aws_security_token, "jobID": job_id, "task": apps.TASK_INFO, "arguments": arguments, } response = invoke_aws_lambda_func(lambdas, str(data).replace('\'','"')) payload = response['Payload'].read() print("{}lambda_info_job{}={}".format(apps.FORMAT_GREEN, apps.FORMAT_RESET, payload)) if len(payload) != 0: return "{}".format(payload)[2:-1] else: return ""
def lambda_terminate_instance(aws_access_key, aws_secret_key, aws_security_token, job_id, arguments): # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/lambda.html lambdas = get_aws_lambda(os.getenv("AWS_ACCESS_KEY_ID"), os.getenv("AWS_SECRET_ACCESS_KEY")) data = { "accessKey": aws_access_key, "secretKey": aws_secret_key, "sessionToken": aws_security_token, "jobID": job_id, "task": apps.TASK_TERMINAL_INSTANCE, "arguments": arguments, } response = invoke_aws_lambda_func(lambdas, str(data).replace('\'','"')) print("{}lambda_terminate_instance{}={}".format(apps.FORMAT_RED, apps.FORMAT_RESET, response['Payload'].read())) if response['StatusCode'] == 200: streambody = response['Payload'].read().decode() print("{}stream_body{}={}".format(apps.FORMAT_BLUE, apps.FORMAT_RESET, streambody)) return True return False
def lambda_import(aws_access_key, aws_secret_key, aws_security_token, job_id,arguments): lambdas = get_aws_lambda(os.getenv("AWS_ACCESS_KEY_ID"), os.getenv("AWS_SECRET_ACCESS_KEY")) data = { "accessKey": aws_access_key, "secretKey": aws_secret_key, "sessionToken": aws_security_token, "jobID": job_id, "task": apps.TASK_IMPORT, "arguments": arguments, } response = invoke_aws_lambda_func(lambdas, str(data).replace('\'','"')) print("{}lambda_terminate_instance{}={}".format(apps.FORMAT_RED, apps.FORMAT_RESET, response['Payload'].read())) if response['StatusCode'] == 200: streambody = response['Payload'].read().decode() print("{}stream_body{}={}".format(apps.FORMAT_BLUE, apps.FORMAT_RESET, streambody)) return True return False