@@ -86,6 +86,50 @@ jsonValue() {
86
86
awk -F" [,:}]" ' {for(i=1;i<=NF;i++){if($i~/' $key ' \042/){print $(i+1)}}}' | tr -d ' "' | sed -n ${num} p
87
87
}
88
88
89
+ installAwsCli () {
90
+ if ! typeExists " pip" ; then
91
+ h2 " Installing Python PIP"
92
+ runCommand " sudo apt-get install -y python-pip"
93
+ success " Installing PIP (` pip --version` ) succeeded"
94
+ fi
95
+
96
+ h2 " Installing AWS CLI"
97
+ runCommand " sudo pip install awscli"
98
+ }
99
+
100
+ vercomp () {
101
+ if [[ $1 == $2 ]]
102
+ then
103
+ return 0
104
+ fi
105
+ local IFS=.
106
+ local i ver1=($1 ) ver2=($2 )
107
+
108
+ # fill empty fields in ver1 with zeros
109
+ for (( i= ${# ver1[@]} ; i< ${# ver2[@]} ; i++ ))
110
+ do
111
+ ver1[i]=0
112
+ done
113
+
114
+ for (( i= 0 ; i< ${# ver1[@]} ; i++ ))
115
+ do
116
+ if [[ -z ${ver2[i]} ]]
117
+ then
118
+ # fill empty fields in ver2 with zeros
119
+ ver2[i]=0
120
+ fi
121
+ if (( 10 #${ver1[i]} > 10 #${ver2[i]} ))
122
+ then
123
+ return 1
124
+ fi
125
+ if (( 10 #${ver1[i]} < 10 #${ver2[i]} ))
126
+ then
127
+ return 2
128
+ fi
129
+ done
130
+ return 0
131
+ }
132
+
89
133
# Check variables
90
134
91
135
if [ -z " $AWS_CODE_DEPLOY_APPLICATION_NAME " ]; then
111
155
112
156
# Check AWS is installed
113
157
h1 " Step 1: Checking Dependencies"
158
+
114
159
if ! typeExists " aws" ; then
115
- if ! typeExists " pip" ; then
116
- h2 " Installing Python PIP"
117
- runCommand " sudo apt-get install -y python-pip"
118
- success " Installing PIP (` pip --version` ) succeeded"
119
- fi
120
-
121
- h2 " Installing AWS CLI"
122
- runCommand " sudo pip install awscli"
160
+ installAwsCli
123
161
success " Installing AWS CLI $( aws --version 2>&1 ) succeeded"
124
162
else
125
- success " Dependencies met (aws: $( aws --version 2>&1 ) )."
163
+ # aws-cli 1.9.8 is required for proper SSE syntax
164
+ AWS_FULL_VER=$( aws --version 2>&1 )
165
+ AWS_VER=$( echo $AWS_FULL_VER | sed -e ' s/aws-cli\///' | sed -e ' s/ Python.*//' )
166
+ vercomp $AWS_VER " 1.9.8"
167
+ if [[ $? == 2 ]]; then
168
+ h2 " Installing updated AWS CLI version ($AWS_VER < 1.9.8)"
169
+ installAwsCli
170
+ fi
171
+
172
+ success " Dependencies met $( aws --version 2>&1 ) "
126
173
fi
127
174
128
175
0 commit comments