Sha256: 414af3609bb93cbbad5f7b0b6449e712461bbac6df1b9c21c20a12570e1eeafb

Contents?: true

Size: 1.1 KB

Versions: 37

Compression:

Stored size: 1.1 KB

Contents

const AWS = require('aws-sdk');

const BUCKET = 'ecs-task-notifications';

exports.handler = (event, context, callback) => {
  const s3 = new AWS.S3();
  // console.log(JSON.stringify(event, null, 2));
  const taskArn = event.detail.taskArn;
  if (event.detail.lastStatus === 'RUNNING' && event.detail.containers.every((container) => container.lastStatus === 'RUNNING')) {
    console.log(`${taskArn} started`);
    s3.putObject({
      Bucket: BUCKET,
      Key: `task_statuses/${taskArn}/started.json`,
      Body: JSON.stringify(event),
    }, (err, data) => {
      if (err) {
        console.log(err);
        callback(err);
      } else {
        callback(null, 'Started');
      }
    });
  } else if (event.detail.lastStatus === 'STOPPED') {
    console.log(`${taskArn} stopped`);
    s3.putObject({
      Bucket: BUCKET,
      Key: `task_statuses/${taskArn}/stopped.json`,
      Body: JSON.stringify(event),
    }, (err, data) => {
      if (err) {
        console.log(err);
        callback(err);
      } else {
        callback(null, 'Stopped');
      }
    });
  } else {
    callback(null, 'Skipped');
  }
};

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
hako-2.17.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.16.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.15.1 examples/put-ecs-container-status-to-s3/index.js
hako-2.15.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.14.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.13.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.12.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.11.1 examples/put-ecs-container-status-to-s3/index.js
hako-2.11.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.10.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.9.2 examples/put-ecs-container-status-to-s3/index.js
hako-2.9.1 examples/put-ecs-container-status-to-s3/index.js
hako-2.9.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.8.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.7.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.6.2 examples/put-ecs-container-status-to-s3/index.js
hako-2.6.1 examples/put-ecs-container-status-to-s3/index.js
hako-2.6.0 examples/put-ecs-container-status-to-s3/index.js
hako-2.5.1 examples/put-ecs-container-status-to-s3/index.js
hako-2.5.0 examples/put-ecs-container-status-to-s3/index.js