Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Derek DeJonghe
committed
Mar 14, 2018
1 parent
6e5d07c
commit 10486f7
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
|
||
import boto3 | ||
import os | ||
import random | ||
import string | ||
|
||
''' | ||
This lambda handler submits a job to a AWS Batch queue. | ||
JobQueue, and JobDefinition environment variables must be set. | ||
These environment variables are intended to be set to the Name, not the Arn. | ||
''' | ||
def lambda_handler(event,context): | ||
# Grab data from environment | ||
jobqueue = os.environ['JobQueue'] | ||
jobdef = os.environ['JobDefinition'] | ||
|
||
# Create unique name for the job (this does not need to be unique) | ||
job1Name = 'job1' + ''.join(random.choices(string.ascii_uppercase + string.digits, k=4)) | ||
|
||
# Set up a batch client | ||
session = boto3.session.Session() | ||
client = session.client('batch') | ||
|
||
# Submit the job | ||
job1 = client.submit_job( | ||
jobName=job1Name, | ||
jobQueue=jobqueue, | ||
jobDefinition=jobdef | ||
) | ||
print("Started Job: {}".format(job1['jobName'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
boto3>=1.6.0 |