-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathrun.sh
executable file
·78 lines (61 loc) · 1.97 KB
/
run.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
###### START: parse command line arguments
SELF_CONTAINED=false
print_usage() {
echo "Usage: $(basename $0) -e <extension_name> -f <function_name> [-s]"
echo " -e: extension/layer name"
echo " -f: lambda fucntion name to be attached to the layer. Function must exist already!!!"
echo " -s: (optional) extension will be publsihed as a standalone package that doesn't depend on any pre-configured runtime. Extension will depend on .NET Core 3.1 lambda runtime if this flag is not set."
}
while getopts ":e:f:sh" opt; do
case ${opt} in
e ) EXTENSION_NAME=$OPTARG
;;
f ) LAMBDA_FUNCTION=$OPTARG
;;
s ) SELF_CONTAINED=true
;;
h )
print_usage
exit 0
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
exit 1
;;
esac
done
shift $((OPTIND -1))
if [ -z "$EXTENSION_NAME" -o -z "$LAMBDA_FUNCTION" ] ; then
print_usage
exit 100
fi
echo "Using configuration:"
echo " Extension/layer name: ${EXTENSION_NAME}"
echo " Lambda function: ${LAMBDA_FUNCTION}"
echo " Self contained deployment: ${SELF_CONTAINED}"
echo ''
###### END: parse command line arguments
rm -rf bin
rm -rf obj
if [ "${SELF_CONTAINED}" = "true" ] ; then
echo 'Building self-contained extension...'
echo ''
dotnet publish -c Release -f net5.0 -p:Platform=x64 -o bin/publish
else
echo 'Building .NET Core 3.1 dependent extension...'
echo ''
dotnet publish -c Release -f netcoreapp3.1 -o bin/publish
fi
cd bin/publish
zip -rm ./deploy.zip *
aws lambda publish-layer-version \
--layer-name "${EXTENSION_NAME}" \
--zip-file "fileb://deploy.zip"
aws lambda update-function-configuration \
--function-name ${LAMBDA_FUNCTION} --layers $(aws lambda list-layer-versions --layer-name ${EXTENSION_NAME} \
--max-items 1 --no-paginate --query 'LayerVersions[0].LayerVersionArn' \
--output text)
cd -