{"id":1890,"date":"2015-11-16T00:00:08","date_gmt":"2015-11-15T15:00:08","guid":{"rendered":"http:\/\/www.magtranetwork.com\/?p=1890"},"modified":"2015-11-16T13:11:14","modified_gmt":"2015-11-16T04:11:14","slug":"amazon_linux_aws_lambda_pdftk","status":"publish","type":"post","link":"https:\/\/www.magtranetwork.com\/aws\/amazon_linux_aws_lambda_pdftk.html","title":{"rendered":"Amazon Linux\u3001AWS Lambda\u3067pdftk\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30fb\u5b9f\u884c\u3059\u308b"},"content":{"rendered":"
Amazon Linux\u306fAWS\u3068\u306e\u89aa\u548c\u6027\u304c\u9ad8\u304fAWS EC2\u4e0a\u306b\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3059\u308b\u969b\u306b\u306f\u6700\u9069\u306a\u9078\u629e\u80a2\u3067\u3059\u3002<\/p>\n
\u3057\u304b\u3057Amazon Linux\u306fpdftk\u3001inkscape\u306a\u3069CentOS\u3067\u306f\u4f7f\u7528\u51fa\u6765\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3082\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3053\u3068\u304c\u96e3\u3057\u3044\u3082\u306e\u304c\u3044\u304f\u3064\u304b\u5b58\u5728\u3059\u308b\u306e\u3082\u4e8b\u5b9f\u3067\u3059\u3002
\n\u3053\u308c\u306f\u81ea\u5206\u306e\u4f7f\u3044\u305f\u3044\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u81ea\u7531\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3067\u304d\u306a\u3044AWS Lambda\u3067\u306f\u66f4\u306b\u30cf\u30fc\u30c9\u30eb\u304c\u9ad8\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n
\u3053\u306e\u3088\u3046\u306a\u5834\u5408\u306f\u7d20\u76f4\u306bCentOS\u3092EC2\u3067\u4f7f\u7528\u3059\u308b\u304b\u3001Amazon Linux\u3001AWS Lambda\u3067\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u76f4\u3059\u304b\u306e\u3069\u3061\u3089\u304b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
\u4eca\u56de\u306f\u3053\u306e\u3088\u3046\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u3046\u3061pdftk\u3092Amazon Linux\u3001AWS Lambda\u3067\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u5099\u5fd8\u9332\u3068\u3057\u3066\u8a18\u8f09\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n
\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001pdftk\u306e\u30bd\u30fc\u30b9\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u89e3\u51cd\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost ~]# yum install gcc gcc-java libgcj libgcj-devel gcc-c++\r\n[root@localhost ~]# curl -L -O https:\/\/www.pdflabs.com\/tools\/pdftk-the-pdf-toolkit\/pdftk-2.02-src.zip\r\n[root@localhost ~]# unzip pdftk-2.02-src.zip\r\n<\/pre>\n\u89e3\u51cd\u3057\u305fpdftk-2.02-dist\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306blibgcj.so.10\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4fdd\u5b58\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3001CentOS\u304b\u3089libgcj.so.10\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30b3\u30d4\u30fc\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost ~]# mkdir -p pdftk-2.02-dist\/lib64\r\n[root@localhost ~]# \\cp -rf \/usr\/lib64\/libgcj.so.10* ~\/pdftk-2.02-dist\/lib64\/\r\n<\/pre>\n\u89e3\u51cd\u3057\u305fpdftk-2.02-dist\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306epdftk\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067pdftk\u306e\u30d0\u30a4\u30ca\u30ea\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost ~]# cd pdftk-2.02-dist\/pdftk\r\n[root@localhost pdftk]# make -f Makefile.Redhat\r\n[root@localhost pdftk]# make -f Makefile.Redhat install\r\n<\/pre>\nlibgcj.so.10\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u30b3\u30d4\u30fc\u3068pdftk\u30d0\u30a4\u30ca\u30ea\u304c\u4f5c\u6210\u3055\u308c\u305fpdftk-2.02-dist\u3092zip\u5727\u7e2e\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost pdftk]# cd ~\r\n[root@localhost ~]# zip -r pdftk-2.02-dist.zip pdftk-2.02-dist\r\n<\/pre>\nAmazon Linux\u3067Amazon Linux\u7528pdftk\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u89e3\u51cd\u3057\u5b9f\u884c\u3059\u308b<\/h3>\n
\u4e0a\u8a18\u3067\u4f5c\u6210\u3057\u305fpdftk-2.02-dist.zip\u3092Amazon Linux\u306b\u914d\u7f6e\u3059\u308b\u3002
\npdftk-2.02-dist.zip\u3092\u89e3\u51cd\u3057\u3001libgcj.so.10\u30e9\u30a4\u30d6\u30e9\u30ea\u3092Amazon Linux\u306e\/usr\/lib64\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u914d\u7f6e\u3059\u308b\u3002<\/p>\n\r\n[root@localhost ~]# unzip pdftk-2.02-dist.zip\r\n[root@localhost ~]# cp pdftk-2.02-dist\/lib64\/libgcj.so.10 \/usr\/lib64\/\r\n<\/pre>\n\u89e3\u51cd\u3057\u305fpdftk-2.02-dist\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306epdftk\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067pdftk\u30d0\u30a4\u30ca\u30ea\u30d5\u30a1\u30a4\u30eb\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb(\u30b3\u30d4\u30fc)\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost ~]# cd pdftk-2.02-dist\/pdftk\/\r\n[root@localhost ~]# make -f Makefile.Redhat install\r\n<\/pre>\npdftk\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u7528\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3002<\/p>\n
\r\n[root@localhost ~]# pdftk --version\r\n<\/pre>\n\u89e3\u51cd\u3057\u305fpdftk-2.02-dist\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068pdftk\u30d0\u30a4\u30ca\u30ea\u3092\u76f4\u63a5\u6307\u5b9a\u3057\u3066\u3082\u5b9f\u884c\u3067\u304d\u308b\u3002<\/p>\n
\r\n[root@localhost ~]# LD_LIBRARY_PATH=\/root\/pdftk-2.02-dist\/lib64\/ \/root\/pdftk-2.02-dist\/pdftk\/pdftk --version\r\n<\/pre>\nAWS Lambda\u3067Amazon Linux\u7528pdftk\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5b9f\u884c\u3059\u308bLambda\u95a2\u6570\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u6210\u3059\u308b<\/h3>\n
AWS Lambda\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308bzip\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3059\u308b\u958b\u767a\u74b0\u5883\u3067\u4f5c\u696d\u3092\u884c\u3046\u3002
\nAWS Lambda\u7528\u306elambda_pdftk\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b\u3002<\/p>\n\r\n[root@localhost ~]# mkdir -p lambda_pdftk\r\n<\/pre>\n\u4e0a\u8a18\u3067\u4f5c\u6210\u3057\u305fpdftk-2.02-dist.zip\u3092\u958b\u767a\u74b0\u5883\u306b\u914d\u7f6e\u3059\u308b\u3002
\npdftk-2.02-dist.zip\u3092lambda_pdftk\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3055\u305b\u89e3\u51cd\u3059\u308b\u3002<\/p>\n\r\n[root@localhost ~]# mv pdftk-2.02-dist.zip lambda_pdftk\/\r\n[root@localhost ~]# cd lambda_pdftk\r\n[root@localhost lambda_pdftk]# unzip pdftk-2.02-dist.zip\r\n[root@localhost lambda_pdftk]# rm -rf pdftk-2.02-dist.zip\r\n<\/pre>\nAWS Lambda Python\u3067\u5b9f\u884c\u3059\u308blambda_function.py\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost lambda_pdftk]# vim lambda_function.py\r\n\r\nimport commands\r\nimport os\r\n\r\nprint('Loading function')\r\n\r\ndef _(cmd):\r\n return commands.getoutput(cmd)\r\n\r\ndef lambda_handler(event, context):\r\n print(_("LD_LIBRARY_PATH=.\/pdftk-2.02-dist\/lib64\/ .\/pdftk-2.02-dist\/pdftk\/pdftk --version"))\r\n<\/pre>\nlambda_function.py\u304c\u8a18\u8ff0\u3067\u304d\u305f\u3089\u6a29\u9650\u3092AWS Lambda\u3067\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u6a29\u9650\u3092\u5909\u66f4\u3057\u518d\u5ea6zip\u5727\u7e2e\u3059\u308b\u3002<\/p>\n
\r\n[root@localhost lambda_pdftk]# chmod 777 -R *\r\n[root@localhost lambda_pdftk]# zip -r lambda_pdftk.zip *\r\n<\/pre>\nAWS Lambda Python\u306blambda_pdftk.zip\u3092\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u5b9f\u884c\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
Amazon Linux\u306fAWS\u3068\u306e\u89aa\u548c\u6027\u304c\u9ad8\u304fAWS EC2\u4e0a\u306b\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u3059\u308b\u969b\u306b\u306f\u6700\u9069\u306a\u9078\u629e\u80a2\u3067\u3059\u3002 \u3057\u304b\u3057Amazon Linux\u306fpdftk\u3001inkscape\u306a\u3069CentOS\u3067\u306f\u4f7f\u7528\u51fa\u6765\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3082\u30a4\u30f3\u30b9 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[3,22,31,79,80,82],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/1890"}],"collection":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/comments?post=1890"}],"version-history":[{"count":1,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/1890\/revisions"}],"predecessor-version":[{"id":1891,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/posts\/1890\/revisions\/1891"}],"wp:attachment":[{"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/media?parent=1890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/categories?post=1890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.magtranetwork.com\/wp-json\/wp\/v2\/tags?post=1890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}