SHARE
TWEET

Untitled

a guest Oct 14th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var AWS = require('aws-sdk');
  2.  
  3. const TASK_ID = 'arc-jupyter-task:9'
  4. const CLUSTER_NAME = 'arc-cluster';
  5. const SUBNET_ID = 'subnet-0e33c61112aa5ed1a';
  6. const NAME = 'arc-jupyter'
  7.  
  8. exports.handler = function (event, context, callback) {
  9.  
  10.     // Each time this lambda function is triggered from an event (probably S3),
  11.     // the event's JSON will be logged. Check Cloud Watch to see the event.
  12.     // You can copy the log from Cloud Watch and use it for testing.
  13.     console.log("====================");
  14.     console.log("REQUEST: " + JSON.stringify(event));
  15.     console.log("====================");
  16.  
  17.     launchJupyter();
  18.  
  19. };
  20.  
  21. function launchJupyter () {
  22.  
  23.     var ecs = new AWS.ECS();
  24.  
  25.     console.log('Deploying a Jupyter Notebook task')
  26.  
  27.     var params = {
  28.         cluster: CLUSTER_NAME,
  29.         taskDefinition: TASK_ID,
  30.         launchType: "FARGATE",
  31.         networkConfiguration: {
  32.             awsvpcConfiguration: {
  33.                 subnets: [
  34.                     SUBNET_ID,
  35.                 ]}
  36.             },
  37.           overrides: {
  38.             containerOverrides: [
  39.               {
  40.                 environment: [
  41.                   {
  42.                     name: "clusterName",
  43.                     value: CLUSTER_NAME
  44.                   }
  45.                 ],
  46.                 name: NAME
  47.               }
  48.             ]
  49.           }
  50.         };
  51.  
  52.     ecs.runTask(params, function(err, data) {
  53.         if (err) console.log(err, err.stack); // an error occurred
  54.         else     console.log(data);           // successful response
  55.     });
  56.  
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top