aws lambda get-policy --query Policy --output text --function-name <function arn>
Get Roles and Security Policies for each function
for f in $(aws lambda list-functions --query "Functions[].FunctionName" --output text); do
ROLE=`aws lambda get-function --function-name $f --query Configuration.Role --output text | awk -F\/ '{print $NF}'`
echo "$f has $ROLE with these managed policies:"
aws iam list-attached-role-policies --role-name $ROLE
for p in `aws iam list-role-policies --role-name $ROLE --query PolicyNames --output text` ; do
echo "$ROLE for $f has inline policy $p:"
aws iam get-role-policy --role-name $ROLE --policy-name $p
done
done
Download source code of all functions
dump_folder="./aws_lambda_dump"
mkdir -p $dump_folder
for f in $(aws lambda list-functions --query "Functions[].FunctionName" --output text); do
wget $(aws lambda get-function --function-name "$f" --query Code.Location --output text) -O "$dump_folder/$f.zip"
mkdir "$dump_folder/$f"
unzip "$dump_folder/$f.zip" -d "$dump_folder/$f"
done