1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 您需要更改在下面代码中的 region, 它将自动将所有Lambda函数的将Python Runtime从3.6更新为3.9。
#!/bin/bash
# listing all functions in csv format using Regular expressions
lambda_fun=$(
aws lambda list-functions \
--function-version ALL \
--region=us-east-2 \
--output text \
--query "Functions[?Runtime=='python3.6'].FunctionName" | sed -E 's/ +/\\n/g')
# adding header to csv and redirecting to file [file.csv]
echo -e "lambda_functions\n$lambda_fun" > file.csv
# updating lambda function by iterating using while loop
i=0
# input file separate
OLDIFS=$IFS
IFS=","
# while loop
while read lambda_functions
do
((i=i+1))
# skipping header
if [ "$i" -eq 1 ]; then
continue
fi
runtime_update=$(
aws lambda update-function-configuration \
--function-name "$lambda_functions" \
--runtime python3.9 --output text --query "Runtime"
)
echo "$lambda_functions" is successfully updated to "$runtime_update"
done < file.csv
IFS=$OLDIFS
相关内容
- 已提问 2 年前
- AWS 官方已更新 4 年前
- AWS 官方已更新 5 个月前