-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-lambda-code.sh
56 lines (49 loc) · 1.25 KB
/
update-lambda-code.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# This only updates an existing lambda function so before running this first create the function.
for i in "$@"
do
case $i in
-d=*|--directory=*)
directory="${i#*=}"
shift # past argument=value
;;
-p=*|--profile=*)
profile="${i#*=}"
shift # past argument=value
;;
-f=*|--function=*)
function="${i#*=}"
shift # past argument=value
;;
-r=*|--region=*)
region="${i#*=}"
shift # past argument=value
;;
*)
# unknown option
;;
esac
done
if [ -z "$profile" ]
then
profile="default"
fi
if [ -z "$function" ]
then
echo "Pass Lambda function name using --lambda-function-name=<lambda-function-name> or -f=<lambda-function-name>"
exit -1
fi
if [ -z "$directory" ]
then
echo "Pass Lambda function directory using --lambda-function-directory=<lambda-function-directory> or -d=<lambda-function-directory>"
exit -1
fi
if [ -z "$region" ]
then
echo "Pass Lambda function region using --region=<lambda-function-region> or -r=<lambda-function-region>"
exit -1
fi
echo "Running with profile=$profile"
bash lambda-zipper.sh $directory
aws lambda --region $region update-function-code --zip-file fileb://lambda.zip --function-name $function --profile $profile
rm lambda.zip