-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdeploy-serverless.sh
More file actions
executable file
·46 lines (40 loc) · 1.72 KB
/
deploy-serverless.sh
File metadata and controls
executable file
·46 lines (40 loc) · 1.72 KB
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
dos2unix configure-environment.sh
source ./configure-environment.sh
export actorsTableArn=$(aws dynamodb describe-table --table-name $actorsTable | jq -r ".Table | select(.TableName==\"$actorsTable\") | .TableArn")
if [ "$actorsTableArn" = "" ]
then
echo "Table $actorsTable does not exits, creating table..."
export actorsTableArn=$(aws dynamodb create-table \
--table-name $actorsTable \
--attribute-definitions 'AttributeName=FirstName,AttributeType=S' 'AttributeName=LastName,AttributeType=S' \
--key-schema 'AttributeName=FirstName,KeyType=HASH' 'AttributeName=LastName,KeyType=RANGE' \
--provisioned-throughput 'ReadCapacityUnits=5,WriteCapacityUnits=5' \
--stream-specification 'StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES' | jq -r ".TableDescription.TableArn")
else
echo "Table $actorsTable exists"
fi
export moviesTableArn=$(aws dynamodb describe-table --table-name $moviesTable | jq -r ".Table | select(.TableName==\"$moviesTable\") | .TableArn")
if [ "$moviesTableArn" = "" ]
then
echo "Table $moviesTable does not exits, creating table..."
export moviesTableArn=$(aws dynamodb create-table \
--table-name $moviesTable \
--attribute-definitions AttributeName=Title,AttributeType=S \
--key-schema AttributeName=Title,KeyType=HASH \
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES | jq -r ".TableDescription.TableArn")
else
echo "Table $moviesTable exists"
fi
cd DynamoDbServerless
dos2unix build.sh
echo "Building and packaging lambda..."
result=$(./build.sh)
if [[ $result == *"error"* ]]; then
echo "ERROR during lambda build"
echo $result
else
echo "Lambda packaged"
fi
sls deploy --region $AwsRegion
cd ..