AWS CLI

AWS Regions

Region Name Region
US East (Ohio) us-east-2
US East (N. Virginia) us-east-1
US West (N. California) us-west-1
US West (Oregon) us-west-2
Asia Pacific (Tokyo) ap-northeast-1
Asia Pacific (Seoul) ap-northeast-2
Asia Pacific (Osaka-Local) ap-northeast-3
Asia Pacific (Mumbai) ap-south-1
Asia Pacific (Singapore) ap-southeast-1
Asia Pacific (Sydney) ap-southeast-2
Canada (Central) ca-central-1
China (Beijing) cn-north-1
China (Ningxia) cn-northwest-1
EU (Frankfurt) eu-central-1
EU (Ireland) eu-west-1
EU (London) eu-west-2
EU (Paris) eu-west-3
South America (São Paulo) sa-east-1

AWS CLi

Lambda

Create Lambda Function Handler1

# -*- coding: UTF-8 -*-

def handler(event, context):
	return {
		'message': 'This is just hello world!'
	}

zip file

# in the work directory
zip -r hello_serverless.zip *

AWS command line2

aws lambda create-function \
--region $AWSREGION \
--function-name HelloServerless \
--zip-file fileb://hello_serverless.zip \
--role arn:aws:iam::$AWSACCOUNTID:role/lambda_basic_execution  \
--handler hello_serverless.handler \
--runtime python3.6 \
--timeout 15 \
--memory-size 512

Return

{
    "FunctionName": "HelloServerless",
    "FunctionArn": "arn:aws:lambda:ap-northeast-2:$AWSACCOUNTID:function:HelloServerless",
    "Runtime": "python3.6",
    "Role": "arn:aws:iam::$AWSACCOUNTID:role/lambda_basic_execution",
    "Handler": "hello_serverless.handler",
    "CodeSize": 293,
    "Description": "",
    "Timeout": 15,
    "MemorySize": 512,
    "LastModified": "2018-08-27T12:28:13.627+0000",
    "CodeSha256": "x/B6/rsGnFF4tSNdjcO2czVk=",
    "Version": "$LATEST",
    "TracingConfig": {
        "Mode": "PassThrough"
    },
    "RevisionId": "32f9d495-4d73-29725ef6237c"
}

Tips: Bash shell script create/update function

#!/bin/bash
rm ./hello_serverless.zip
zip -r hello_serverless.zip *

string=$(aws lambda list-functions)
if [[ $string = *"HelloServerless"* ]]; then
	aws lambda update-function-code --region $AWSREGION --function-name HelloServerless --zip-file fileb://hello_serverless.zip 
else 
	aws lambda create-function --region $AWSREGION --function-name HelloServerless --zip-file fileb://hello_serverless.zip --role arn:aws:iam::$AWSACCOUNTID:role/lambda_basic_execution  --handler hello_serverless.handler --runtime python3.6 --timeout 15 --memory-size 512
fi

Working with packages3. There is a example for Lambda deployment with Python package4

virtualenv env # default pyton 3.6
source env/bin/activate
pip install -r requirements.txt

cp -rf <your-source-code.py> dist
cp -rf env/lib/python3.6/site-packages/* dist
cd dist
zip -r deployment_package.zip .
# aws cli upload

Invoke It Manually https://docs.aws.amazon.com/lambda/latest/dg/with-on-demand-custom-android-example-upload-deployment-pkg.html