{"id":607,"date":"2020-01-31T12:01:48","date_gmt":"2020-01-31T03:01:48","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/01\/31\/yum-lambda"},"modified":"2020-01-31T12:01:48","modified_gmt":"2020-01-31T03:01:48","slug":"yum-lambda","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2020\/01\/31\/yum-lambda\/","title":{"rendered":"yum\u3067\u5165\u308c\u305f\u4f9d\u5b58\u30e2\u30b8\u30e5\u30fc\u30eb\u3092AWS Lambda\u3067\u4f7f\u3046\u65b9\u6cd5"},"content":{"rendered":"
\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u5185\u5c71\u3067\u3059\u3002\u6700\u8fd1\u306f\u8da3\u5473\u306e\u95a2\u4fc2\u3067\u3001\u8eca\u3067\u9060\u51fa\u3059\u308b\u3053\u3068\u304c\u591a\u304f\u306a\u308a\u3001\u534a\u5e74\u307b\u3069\u3067\u8d70\u884c\u8ddd\u96e2\u304c10000km\u3092\u7a81\u7834\u3057\u307e\u3057\u305f\u3002<\/p>\n
\u672c\u8a18\u4e8b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5185\u5bb9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
Docker\u3068Serverless Framework\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u308b\u3053\u3068\u304c\u524d\u63d0\u3067\u3059\u3002<\/p>\n
Docker Serverless Framework \u4f9d\u5b58\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30d3\u30eb\u30c9\u306f\u3001Docker\u3092\u5229\u7528\u3057\u307e\u3059\u3002\u307e\u305f\u3001Docker\u306e\u30d3\u30eb\u30c9\u4f5c\u696d\u3092\u697d\u306b\u3057\u3066\u304f\u308c\u308byumda\u3068\u3044\u3046\u30c4\u30fc\u30eb\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n yumda \u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7c21\u5358\u306byum\u30b3\u30de\u30f3\u30c9\u3092Docker\u30b3\u30f3\u30c6\u30ca\u4e0a\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n \u4f8b\u3048\u3070\u3001Amazon Linux 2\u3067\u3001Ghostscript\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30de\u30f3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068 dependencies \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3001Ghostscript\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3059\u3002<\/p>\n \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3054\u3068zip\u3067\u56fa\u3081\u307e\u3059\u3002<\/p>\n \u307e\u305f\u3001 Serverless Framework \u306e\u8a2d\u5b9a\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n layers\u9805\u76ee\u3067Lambda Layer\u306e\u8a2d\u5b9a\u3092\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u8a2d\u5b9a\u306b\u3088\u308a\u3001dependencies.zip\u306fLambda Layer\u306b\u914d\u7f6e\u3055\u308c\u307e\u3059\u3002<\/p>\n Lambda Layer\u3068\u3044\u3046\u306e\u306f\u3001\u8907\u6570\u306eLambda\u95a2\u6570\u3067\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u5171\u6709\u3059\u308b\u4ed5\u7d44\u307f\u3067\u3059\u3002\u3053\u306e\u4ed5\u7d44\u307f\u306b\u3088\u308a\u3001\u4eca\u56de\u3067\u306fGhostscript\u3092\u8907\u6570\u306eLambda\u95a2\u6570\u304b\u3089\u547c\u3073\u51fa\u305b\u308b\u5f62\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n \u30c7\u30d7\u30ed\u30a4\u30b3\u30de\u30f3\u30c9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n yum\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u4f9d\u5b58\u30e2\u30b8\u30e5\u30fc\u30eb\u3092Lambda\u95a2\u6570\u3067\u5229\u7528\u3059\u308b\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n yum\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306f\u3001yumda\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u7ba1\u7406\u3057\u3066\u3044\u308b\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u53c2\u7167\u3057\u3066\u3044\u308b\u306e\u3067\u3001\u4ee5\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u30ea\u30b9\u30c8\u3055\u308c\u3066\u3044\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u4ee5\u5916\u306f\u5229\u7528\u3067\u304d\u307e\u305b\u3093\u3002<\/p>\n https:\/\/github.com\/lambci\/yumda\/blob\/master\/amazon-linux-2\/packages.txt<\/a><\/p>\n \u542b\u307e\u308c\u3066\u3044\u306a\u3044\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5229\u7528\u3057\u305f\u3044\u5834\u5408\u306f\u3001Issues\u3067\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u51fa\u3059\u3068\u826f\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n MMM\u306f\u3001AWS Lambda\u3068Docker\u30b3\u30f3\u30c6\u30ca\u306b\u529b\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u3002\u305c\u3072\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3092\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n
\nhttps:\/\/www.docker.com\/<\/a><\/p>\n
\nhttps:\/\/serverless.com\/<\/a><\/p>\nDocker\u3068yumda\u3092\u5229\u7528\u3057\u3066\u3001\u4f9d\u5b58\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30d3\u30eb\u30c9<\/h2>\n
\nhttps:\/\/github.com\/lambci\/yumda<\/a><\/p>\n$ docker run lambci\/yumda:<version> yum <yum-args><\/code><\/pre>\n
<version><\/code> \u306f\u3001Amazon Linux\u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u3067\u3059\u3002<\/p>\n
$ mkdir -p dependencies\n$ docker run --rm -v "$PWD"\/dependencies:\/lambda\/opt lambci\/yumda:2 yum install -y ghostscript <\/code><\/pre>\n
Serverless Framework\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b<\/h2>\n
$ cd dependencies\n$ zip -yr ..\/dependencies.zip .\n$ cd ..<\/code><\/pre>\n
hello-world\/app.js<\/code> \u3068\u3044\u3046\u540d\u524d\u3067\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n
service: yumda-example\n\nprovider:\n name: aws\n runtime: nodejs10.x\n\npackage:\n individually: true\n exclude:\n - .\/**\n\nfunctions:\n hello-world:\n handler: hello-world\/app.lambdaHandler\n package:\n include:\n - hello-world\/**\n layers:\n - {Ref: DependenciesLambdaLayer}\n\nlayers:\n dependencies:\n path: dependencies\n package:\n artifact: dependencies.zip<\/code><\/pre>\n
$ sls deploy<\/code><\/pre>\n
\u307e\u3068\u3081<\/h2>\n