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

0

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

profile picture
EXPERTO
preguntada hace 2 años33 visualizaciones
1 Respuesta
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
EXPERTO
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas