Skip to content

Commit

Permalink
GITBOOK-652: change request with no subject merged in GitBook
Browse files Browse the repository at this point in the history
  • Loading branch information
fborsani authored and gitbook-bot committed May 2, 2024
1 parent 56af3ec commit 8725060
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cloud-aws/lambda-function.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,20 @@

## Enumeration

Get function list

```
aws lambda list-functions
```

Get function information

```
aws lambda list-functions --query "Functions[].[FunctionName, FunctionArn, Description, Role, Runtime, Handler, VpcConfig.VpcId, VpcConfig.SubnetIds[], VpcConfig.SecurityGroupIds[]]"
```

Get full function information

```
aws lambda get-function --function-name <function arn>
```
Expand All @@ -20,3 +32,28 @@ Get security policies
aws lambda get-policy --query Policy --output text --function-name <function arn>
```

Get Roles and Security Policies for each function

```bash
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

```bash
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_folderp/$f.zip" -d "$dump_folder/$f"
done
```

0 comments on commit 8725060

Please sign in to comment.