Help us understand the problem. What is going on with this article?

Serverless FrameworkでTypeScriptを使い、Lambda Layersを使う方法

serverless framework自体をインストールする

npm install -g serverless

プロジェクトを作成する

serverless create --template aws-nodejs-typescript --path my-service

プラグインインストール

serverless plugin install -n serverless-webpack
npm install

デプロイ

serverless deploy --aws-profile sandbox -v

デプロイされると、 endpoints にURLが表示されています。

そのURLにcurlでアクセスしてみます。

curl https://hsnfe8svli.execute-api.us-east-1.amazonaws.com/dev/hello | jq

実行すると下記の結果が得られます。(抜粋)

{
  "message": "Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!"
}

実行してみる

serverless invoke -f hello -l --aws-profile sandbox

出力

{
    "statusCode": 200,
    "body": "{\n  \"message\": \"Go Serverless Webpack (Typescript) v1.0! Your function executed successfully!\",\n  \"input\": {}\n}"
}
--------------------------------------------------------------------
START RequestId: d2d32d7e-7c23-448d-ac57-45133fcf6422 Version: $LATEST
END RequestId: d2d32d7e-7c23-448d-ac57-45133fcf6422
REPORT RequestId: d2d32d7e-7c23-448d-ac57-45133fcf6422  Duration: 2.07 ms   Billed Duration: 100 ms Memory Size: 1024 MB    Max Memory Used: 76 MB

Layersプラグインを使う

npx sls plugin install --name serverless-layers

S3 Bucketを指定する

serverless info -v

で表示される、ServerlessDeploymentBucketName を、serverless.yamlのcustomセクションに追加

custom:
  serverless-layers:
    layersDeploymentBucket: 'ここにServerlessDeploymentBucketNameの値を入れる'

(いちいちこの方法を使わないでも直接参照したい…。だれか知っている人がいたら教えてください)

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした