用于将Lambda函数中的Python Runtime从3.6更新到3.9的脚本

0

【以下的问题经过翻译处理】 我有多个Lambda函数。是否有脚本可以将Lambda函数中Python Runtime从3.6更新到3.9?谢谢。

profile picture
专家
已提问 2 年前30 查看次数
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

profile picture
专家
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则