我正在尝试通过 AWS lambda 调用批处理操作。我希望批处理 return 输出到我的 lambda
I am trying to invoke a batch operation through AWS lambda. I want the batch to return the output to my lambda
我正在通过 AWS Lambda 调用批处理作业。可以在 cloudwatch 日志中看到输出,但是我希望 AWS 批处理的输出显示在 lambda 日志中,因为我打算将 API 与 lambda 集成。 Lambda 是我的输入源。
代码:
import boto3
import json
def lambda_handler(event, context):
client = boto3.client('batch') JOB_NAME = event["JobName"]
JOB_QUEUE = "arn:aws:batch:ap-south-1:998338321653:job-queue/estimate-pi"
JOB_DEFINITION = "arn:aws:batch:ap-south-1:998338321653:job-definition/test_batch_v2:12"
response = client.submit_job(jobName = JOB_NAME, jobQueue = JOB_QUEUE, jobDefinition = JOB_DEFINITION, parameters = { "D": json.dumps(event)})
print(response)
return (response)
一个可能的选择是使用您在提交 AWS Batch 时收到的 JobId 从您的 lambda 函数调用 describeJobs API. You can then get the logStream from the container and get the logEvents。
我正在通过 AWS Lambda 调用批处理作业。可以在 cloudwatch 日志中看到输出,但是我希望 AWS 批处理的输出显示在 lambda 日志中,因为我打算将 API 与 lambda 集成。 Lambda 是我的输入源。
代码:
import boto3
import json
def lambda_handler(event, context):
client = boto3.client('batch') JOB_NAME = event["JobName"]
JOB_QUEUE = "arn:aws:batch:ap-south-1:998338321653:job-queue/estimate-pi"
JOB_DEFINITION = "arn:aws:batch:ap-south-1:998338321653:job-definition/test_batch_v2:12"
response = client.submit_job(jobName = JOB_NAME, jobQueue = JOB_QUEUE, jobDefinition = JOB_DEFINITION, parameters = { "D": json.dumps(event)})
print(response)
return (response)
一个可能的选择是使用您在提交 AWS Batch 时收到的 JobId 从您的 lambda 函数调用 describeJobs API. You can then get the logStream from the container and get the logEvents。