I want to use API gateway with AWS batch
I already know how to use API Gateway with AWS lambda naad since there is a limit of 250 MB in lambda, I am not able to use it for integration and now trying AWS batch
I want to use API gateway with AWS batch
I already know how to use API Gateway with AWS lambda naad since there is a limit of 250 MB in lambda, I am not able to use it for integration and now trying AWS batch
I am assuming that you want to use API Gateway + Lambda to create an endpoint for submitting job requests to AWS Batch.
In order to do so create the following Lambda function, which submits a job to AWS Batch. Replace "jobQueueArn" with the arn of your job queue. Integrate the Lambda function with API Gateway.
import boto3
def lambda_handler(event, context):
client = boto3.client('batch')
JOB_NAME = event['JobName']
JOB_QUEUE = "jobQueueArn"
JOB_DEFINITION = "a-job-definition:1"
response = client.submit_job(
jobName = JOB_NAME,
jobQueue = JOB_QUEUE,
jobDefinition = JOB_DEFINITION,
parameters = { 'key': 'value' }
)
print(response)
return 0
Parameters can be passed using the parameters
input.
parameters (dict) -- Additional parameters passed to the job that replace parameter substitution placeholders that are set in the job definition. Parameters are specified as a key and value pair mapping. Parameters in a SubmitJob request override any corresponding parameter defaults from the job definition.
Make sure to attach the proper IAM policy to the Lambda Function's role.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": [
"batch:SubmitJob"
],
"Resource": [
"*"
]
}
]
}