Demo1 透過AWS Lambda 備份S3資料
Demo2 改變上傳的圖片大小及如何使用套件
透過AWS Lambda來備份S3檔案
Python 版本: 2.7
範例程式將會透過放資料到S3上來驅動AWS Lambda執行,建議使用AWS有Admin權限的帳號來操作
工作流程如下: 上傳檔案 -> S3 bucket 1號 -> 驅動Lambda -> 複製檔案 -> 放到S3 bucket2號
使用的AWS服務:
-
AWS Lambda: 複製S3的檔案到另一個bucket中
-
AWS S3: 提供放入檔案的bucket驅動AWS Lambda後,輸出檔案到另一個bucket
-
AWS IAM Role: 分配AWS Lambda程式的權限能操作S3所有資源並有基本執行Lambda服務的權限
透過AWS Lambda改變圖片大小
Python 版本: 3.6
如何安裝Python套件
pip install module-name -t /path/to/project-dir
(如果是需要C或C++等需要Compile的套件,請使用AWS Linux image基底的作業系統compile
請不要將Windows compile的套件上傳, 可參考 Reference)
使用AWS Lambda 轉換圖片成不同大小的圖片提供給各個裝置使用,建議使用AWS有Admin權限的帳號來操作
記得將resize_image底下的lambda_function.py中的
SOURCE_BUCKET
以及RESIZE_BUCKET
後的變數改成對應的S3 Bucket名稱
使用的AWS服務:
-
AWS Lambda: 轉換圖片成不同大小的圖片
-
AWS S3: 提供放入檔案的bucket驅動AWS Lambda後,輸出檔案到另一個bucket
-
AWS IAM Role: 分配AWS Lambda程式的權限能操作S3所有資源並有基本執行Lambda服務的權限
Demo1 Backup S3 by AWS Lambda
Demo2 Resize Image and How to Deploy New Module
Backup S3 by AWS Lambda Python version: 2.7
This sample code will demo how to trigger AWS Lambda by putting object to AWS S3. Please use AWS Admin account manipulate the tutorial
The workflow see below:
upload file -> S3 bucket1 -> trigger Lambda -> copy object -> S3 bucket2
Use AWS service:
-
AWS Lambda: copy S3 object to the other bucket
-
AWS S3: save input data, output data and trigger AWS Lambda
-
AWS IAM Role: assign AWS Lambda to full access S3 and basic execution
Resize image by AWS Lambda
Python version: 3.6
How to deploy new module
pip install module-name -t /path/to/project-dir
(if need compile by C or C++ , please use AWS Linux image compile.
Do not use windows library upload, see Reference)
Use AWS Lambda convert image to different size for multiple devices.
Please use AWS Admin account manipulate the tutorial
Please modify lambda_function.py content
(SOURCE_BUCKET
and RESIZE_BUCKET
varible to correct S3 bucket name)
in resize_image folder
Use AWS service:
-
AWS Lambda: convert image from large to small
-
AWS S3: save input data, output data and trigger AWS Lambda
-
AWS IAM Role: assign AWS Lambda to full access S3 and basic execution
-
Tutorial by Node.js http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html
-
Compile OS version for Python or Node.js http://docs.aws.amazon.com/lambda/latest/dg/current-supported-versions.html