-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-dms-instance.bash
executable file
·73 lines (49 loc) · 1.8 KB
/
create-dms-instance.bash
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
#! /bin/bash
echo $#
# make sure user passed correct number of parameters
if [ $# -ne 6 ] ; then
echo "6 arguments required: <instance-identifier> <instance-class> <engine-version> <allocated-storage-gb> <subnet-group> <security-group>"
exit 1
fi
DMS_INSTANCE_IDENTIFIER=$1
DMS_INSTANCE_CLASS=$2
DMS_ENGINE_VERSION=$3
DMS_ALLOCATED_STORAGE=$4
DMS_SUBNET_GROUP=$5
DMS_SECURITY_GROUP=$6
include --no-multi-az
# number of seconds to wait before looking for progress
sleepSeconds=5
# bash stuff
# check if not set or empty
# : "${BATCHNUM:?Variable not set or empty}"
# use default value if not set or empty
# : "${BATCHNUM:=3}"
# create the instance
echo "... creating cluster $DMS_CLUSTER_IDENTIFIER"
instanceCreateInfo=`aws dms create-replication-instance \
--replication-instance-identifier $DMS_INSTANCE_IDENTIFIER \
--replication-instance-class $DMS_INSTANCE_CLASS \
--engine-version $DMS_ENGINE_VERSION \
--allocated-storage $DMS_ALLOCATED_STORAGE \
--replication-subnet-group-identifier $DMS_SUBNET_GROUP \
--vpc-security-group-ids "$DMS_SECURITY_GROUP" \
--no-multi-az \
--no-auto-minor-version-upgrade`
echo $instanceCreateInfo
#dbClusterArn=`echo $clusterCreateInfo | jq -r '.DBCluster.DBClusterArn'`
# watch for cluster to be "available"
T="$(date +%s)"
instanceStatus='unknown'
exit 1
while true ; do
clusterInfo=`aws docdb describe-db-clusters --db-cluster-identifier $DDB_DB_CLUSTER_IDENTIFIER`
clusterStatus=`echo $clusterInfo | jq -r '.DBClusters[0].Status'`
T2="$(($(date +%s)-T))"
thisDuration=`printf "%02d:%02d:%02d:%02d" "$((T2/86400))" "$((T2/3600%24))" "$((T2/60%60))" "$((T2%60))"`
echo "$thisDuration | waiting for cluster creation to complete"
if [[ "$clusterStatus" == "available" ]] ; then
break
fi
sleep $sleepSeconds
done