@@ -86,15 +86,6 @@ jsonValue() {
86
86
}
87
87
88
88
# Check variables
89
- if [ -z " $AWS_CODE_DEPLOY_KEY " ]; then
90
- error " Please set the \"\$ AWS_CODE_DEPLOY_KEY\" variable"
91
- exit 1
92
- fi
93
-
94
- if [ -z " $AWS_CODE_DEPLOY_SECRET " ]; then
95
- error " Please set the \"\$ AWS_CODE_DEPLOY_SECRET\" variable"
96
- exit 1
97
- fi
98
89
99
90
if [ -z " $AWS_CODE_DEPLOY_APPLICATION_NAME " ]; then
100
91
error " Please set the \"\$ AWS_CODE_DEPLOY_APPLICATION_NAME\" variable"
@@ -130,7 +121,7 @@ if ! typeExists "aws"; then
130
121
runCommand " sudo pip install awscli"
131
122
success " Installing AWS CLI (` aws --version` ) succeeded"
132
123
else
133
- success " Dependencies met."
124
+ success " Depenencies met."
134
125
fi
135
126
136
127
141
132
# ----------------------
142
133
143
134
h1 " Step 2: Configuring AWS"
144
- h2 " Configuring AWS Access Key ID"
145
- CONFIGURE_KEY_OUTPUT=$( aws configure set aws_access_key_id $AWS_CODE_DEPLOY_KEY 2>&1 )
146
- success " Configuring AWS Access Key ID succeeded"
147
- h2 " Configuring AWS Secret Access Key"
148
- CONFIGURE_SECRET_OUTPUT=$( aws configure set aws_secret_access_key $AWS_CODE_DEPLOY_SECRET 2>&1 )
149
- success " Configuring AWS Secret Access Key succeeded"
150
-
151
- if [ -n " $AWS_CODE_DEPLOY_REGION " ]; then
152
- h2 " Configuring AWS default region"
135
+ if [ -z " $AWS_CODE_DEPLOY_KEY " ]; then
136
+ if [ ! -e ~ /.aws/config ]; then
137
+ error " Please configure AWS credentials or explicitly set the \"\$ AWS_CODE_DEPLOY_KEY\" variable"
138
+ exit 1
139
+ fi
140
+ if [ $( grep aws_access_key_id ~ /.aws/config | wc -l) -lt 1 ]; then
141
+ error " Unable to find \" aws_access_key_id\" in ~/.aws/config. Please configure AWS credentials or explicitly set the \"\$ AWS_CODE_DEPLOY_KEY\" variable"
142
+ exit 1
143
+ fi
144
+ success " AWS Access Key already configured."
145
+ else
146
+ CONFIGURE_KEY_OUTPUT=$( aws configure set aws_access_key_id $AWS_CODE_DEPLOY_KEY 2>&1 )
147
+ success " Successfully configured AWS Access Key ID."
148
+ fi
149
+
150
+ if [ -z " $AWS_CODE_DEPLOY_SECRET " ]; then
151
+ if [ ! -e ~ /.aws/config ]; then
152
+ error " Please configure AWS credentials or explicitly set the \"\$ AWS_CODE_DEPLOY_SECRET\" variable"
153
+ exit 1
154
+ fi
155
+ if [ $( grep aws_secret_access_key ~ /.aws/config | wc -l) -lt 1 ]; then
156
+ error " Unable to find \" aws_secret_access_key\" in ~/.aws/config. Please configure AWS credentials or explicitly set the \"\$ AWS_CODE_DEPLOY_SECRET\" variable"
157
+ exit 1
158
+ fi
159
+ success " AWS Secret Access Key already configured."
160
+ else
161
+ CONFIGURE_KEY_OUTPUT=$( aws configure set aws_secret_access_key $AWS_CODE_DEPLOY_SECRET 2>&1 )
162
+ success " Successfully configured AWS Secret Access Key ID."
163
+ fi
164
+
165
+ if [ -z " $AWS_CODE_DEPLOY_REGION " ]; then
166
+ if [ -e ~ /.aws/config ]; then
167
+ if [ $( grep region ~ /.aws/config | wc -l) -lt 1 ]; then
168
+ warnNotice " Unable to configure AWS region."
169
+ else
170
+ success " AWS Region already configured."
171
+ fi
172
+ fi
173
+ else
153
174
CONFIGURE_REGION_OUTPUT=$( aws configure set default.region $AWS_CODE_DEPLOY_REGION 2>&1 )
154
- success " Configuring AWS default region succeeded "
175
+ success " Successfully configured AWS default region. "
155
176
fi
156
177
157
178
@@ -381,8 +402,6 @@ runCommand "$REGISTER_APP_CMD" \
381
402
# see documentation http://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment.html
382
403
# ----------------------
383
404
DEPLOYMENT_DESCRIPTION=" $AWS_CODE_DEPLOY_DEPLOYMENT_DESCRIPTION "
384
- DEPLOYMENT_OVERVIEW=${AWS_CODE_DEPLOY_DEPLOYMENT_OVERVIEW:- true}
385
-
386
405
h1 " Step 10: Creating Deployment"
387
406
DEPLOYMENT_CMD=" aws deploy create-deployment --application-name $APPLICATION_NAME --deployment-config-name $DEPLOYMENT_CONFIG_NAME --deployment-group-name $DEPLOYMENT_GROUP --s3-location $S3_LOCATION "
388
407
@@ -405,6 +424,7 @@ note "You can follow your deployment at: https://console.aws.amazon.com/codedepl
405
424
# ----- Monitor Deployment -----
406
425
# see documentation http://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment.html
407
426
# ----------------------
427
+ DEPLOYMENT_OVERVIEW=${AWS_CODE_DEPLOY_DEPLOYMENT_OVERVIEW:- true}
408
428
if [ " true" = " $DEPLOYMENT_OVERVIEW " ]; then
409
429
h1 " Deployment Overview"
410
430
@@ -515,10 +535,8 @@ if [ "true" = "$DEPLOYMENT_OVERVIEW" ]; then
515
535
continue
516
536
fi
517
537
518
- # Attempt to get error message
519
- ERROR_CODE=$( echo $line | sed -r ' s/DIAGNOSTICS//g' | sed -r ' s/LifecycleEvent\s-\s[a-zA-Z]+//g' )
520
- printf " ${red} Error Code: %s${reset} \n" $ERROR_CODE
521
- printf " ${red} Error Log:${reset} \n"
538
+ # Just pipe off the DIAGNOSTICS
539
+ printf " ${red} %s${reset} \n" " $( echo $line | sed -r ' s/^DIAGNOSTICS\s*//g' ) "
522
540
;;
523
541
524
542
* )
0 commit comments