Last active
September 26, 2019 11:15
-
-
Save MitchyBAwesome/46dd2644950a627c68a21ccd6a8e5bbe to your computer and use it in GitHub Desktop.
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
var AWS = require('aws-sdk'); | |
const TASK_ID = 'arc-jupyter-task:9' | |
const CLUSTER_NAME = 'arc-cluster'; | |
const SUBNET_ID = 'subnet-0e33c61112aa5ed1a'; | |
const NAME = 'arc-jupyter' | |
exports.handler = function (event, context, callback) { | |
// Each time this lambda function is triggered from an event (probably S3), | |
// the event's JSON will be logged. Check Cloud Watch to see the event. | |
// You can copy the log from Cloud Watch and use it for testing. | |
console.log("===================="); | |
console.log("REQUEST: " + JSON.stringify(event)); | |
console.log("===================="); | |
launchJupyter(); | |
}; | |
function launchJupyter () { | |
var ecs = new AWS.ECS(); | |
console.log('Deploying a Jupyter Notebook task') | |
var params = { | |
cluster: CLUSTER_NAME, | |
taskDefinition: TASK_ID, | |
launchType: "FARGATE", | |
networkConfiguration: { | |
awsvpcConfiguration: { | |
subnets: [ | |
SUBNET_ID, | |
]} | |
}, | |
overrides: { | |
containerOverrides: [ | |
{ | |
environment: [ | |
{ | |
name: "clusterName", | |
value: CLUSTER_NAME | |
} | |
], | |
name: NAME | |
} | |
] | |
} | |
}; | |
ecs.runTask(params, function(err, data) { | |
if (err) console.log(err, err.stack); // an error occurred | |
else console.log(data); // successful response | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment