阿里云函数计算最近开始取消每个月的免费额度,吃相难看。虽然我平时跑跑个人的定时任务,用到的资源很少,还是决定迁移到别的平台。让它日活-1也算我做的一个贡献吧。
1/ 安装 aws CLI
https://docs.aws.amazon.com/cli/latest/userguide/getting-started-version.html
2/ aws configure
https://docs.aws.amazon.com/cli/latest/userguide/welcome-examples.html
里面需要的秘钥可以到 https://us-east-1.console.aws.amazon.com/iam/home?region=us-east-1#/security_credentials 创建。
3/ Create lambda by CLI
aws iam create-role --role-name lambda-ex --assume-role-policy-document '{"Version": "2012-10-17","Statement": [{ "Effect": "Allow", "Principal": {"Service": "lambda.amazonaws.com"}, "Action": "sts:AssumeRole"}]}'
zip function.zip index.js
# 创建
aws lambda create-function --function-name my-function --zip-file fileb://function.zip --handler index.handler --runtime nodejs16.x --role arn:aws:iam::044694559979:role/lambda-ex
# 查看和更新
aws lambda invoke --function-name my-function out --log-type Tail --query 'LogResult' --output text | base64 -d
aws lambda list-functions
aws lambda update-function-configuration --function-name my-function --memory-size 256
# 其他命令
aws lambda help
4/ CLI debug
https://docs.aws.amazon.com/lambda/latest/dg/python-exceptions.html#python-exceptions-cli
aws lambda invoke \
--function-name my-function \
--cli-binary-format raw-in-base64-out \
--payload '{"key1": "value1", "key2": "value2", "key3": "value3"}' output.txt
标签:function,name,--,aws,阿里,com,lambda
From: https://www.cnblogs.com/jneeee/p/16884646.html