Upgrade to Pro — share decks privately, control downloads, hide ads and more …

gunmaweb-serverless

 gunmaweb-serverless

kanayannet

March 06, 2021
Tweet

More Decks by kanayannet

Other Decks in Programming

Transcript

  1. 関数を動かそうと思ったら… 1. OS を⽤意 2. xx ⾔語をinstall 3. 実⾏するPG を⽤意

    4. ライブラリを作成 5. 「4 」を「3 」で読み込む 6. 「4 」を実⾏する「トリガー」を記述する 7. 「トリガー」を踏めば、実⾏される
  2. 具体的な実装例 参考: const AWS = require('aws-sdk'); const util = require('util');

    const sharp = require('sharp'); // get reference to S3 client const s3 = new AWS.S3(); exports.handler = async (event, context, callback) => { // Read options from the event parameter. console.log("Reading options from event:\n", util.inspect(ev const srcBucket = event.Records[0].s3.bucket.name; // Object key may have spaces or unicode non-ASCII characte const srcKey = decodeURIComponent(event.Records[0].s3.ob const dstBucket = srcBucket + "-resized"; https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/with-s3-example-deployment-pkg.html