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

0

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

profile picture
전문가
질문됨 2년 전33회 조회
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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠