aws lambda get-policy --query Policy --output text --function-name <function arn>
Get Roles and Security Policies for each function
for f in $(awslambdalist-functions--query"Functions[].FunctionName"--outputtext); do ROLE=`awslambdaget-function--function-name $f --queryConfiguration.Role--outputtext|awk-F\/ '{print $NF}'`echo"$f has $ROLE with these managed policies:"awsiamlist-attached-role-policies--role-name $ROLEfor p in`awsiamlist-role-policies--role-name $ROLE --queryPolicyNames--outputtext` ; doecho"$ROLE for $f has inline policy $p:"awsiamget-role-policy--role-name $ROLE --policy-name $pdonedone
Download source code of all functions
dump_folder="./aws_lambda_dump"mkdir-p $dump_folderfor f in $(awslambdalist-functions--query"Functions[].FunctionName"--outputtext); dowget $(awslambdaget-function--function-name"$f"--queryCode.Location--outputtext) -O"$dump_folder/$f.zip"mkdir"$dump_folder/$f"unzip"$dump_folder/$f.zip"-d"$dump_folder/$f"done