Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement