-
Notifications
You must be signed in to change notification settings - Fork 2
/
deploy.sh
executable file
·37 lines (31 loc) · 1.1 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
PORTS_LAMBDA_WORKER_ZIP='workercode-portscan.zip'
NMAP_LAMBDA_WORKER_ZIP='workercode-nmap.zip'
BUCKET_NAME='lambdaportscanner'
ROLE_NAME='lambdaportscanner'
function create_bucket() {
aws s3api create-bucket --bucket $BUCKET_NAME | jq '.Location'
}
function upload_code_zips() {
aws s3 cp $PORTS_LAMBDA_WORKER_ZIP "s3://$BUCKET_NAME/$PORTS_LAMBDA_WORKER_ZIP"
aws s3 cp $NMAP_LAMBDA_WORKER_ZIP "s3://$BUCKET_NAME/$NMAP_LAMBDA_WORKER_ZIP"
}
function create_role() {
ROLE_ARN=`aws iam create-role --path '/service-role/' \
--role-name $ROLE_NAME \
--assume-role-policy-document file://role-trust-policy.json | jq '.Role.Arn'`
}
function main() {
echo "[*] Creating S3 bucket"
create_bucket
echo "[*] Uploading code ZIP files"
upload_code_zips
echo "[*] Creating Lambda IAM Execution Role"
create_role
echo "** Use these for controller arguments: **"
echo "--role $ROLE_ARN"
echo "For portscan command: --s3-zip $BUCKET_NAME/$PORTS_LAMBDA_WORKER_ZIP"
echo "For nmap command: --s3-zip $BUCKET_NAME/$NMAP_LAMBDA_WORKER_ZIP"
}
main
exit 0