@@ -45,7 +45,7 @@ APP_IMAGE_NAME=""
45
45
DOCKERRUN=" Dockerrun.aws.json"
46
46
# EBS_EB_EXTENSTION_LOCATION=""
47
47
IMG_WITH_EBS_TAG=" "
48
- EBS_TEMPLATE_SKELETON_FILE=" ebs_base_template_v2 .json.template"
48
+ EBS_TEMPLATE_SKELETON_FILE=" ebs_base_template_v3 .json.template"
49
49
EBS_APPLICATION_NAME=" "
50
50
EBS_APPVER=" "
51
51
EBS_TAG=" "
@@ -58,7 +58,8 @@ EBS_TEMPLATE_FILE_NAME=""
58
58
# AWS_EBS_EB_DOCKERRUN_TEMPLATE_LOCATION=$(eval "echo \$${ENV}_AWS_EBS_EB_DOCKERRUN_TEMPLATE_LOCATION")
59
59
# AWS_EBS_DOCKERRUN_TEMPLATE=$(eval "echo \$${ENV}_AWS_EBS_DOCKERRUN_TEMPLATE")
60
60
# AWS_S3_KEY_LOCATION=""
61
-
61
+ ebsportcount=0
62
+ ebstemplate=" "
62
63
# variable for cloud front
63
64
# AWS_S3_BUCKET=""
64
65
# AWS_S3_SOURCE_SYNC_PATH=""
@@ -418,6 +419,22 @@ validate_update_loggroup()
418
419
}
419
420
# EBS integration
420
421
422
+ ebsportmapping () {
423
+ echo " port map called"
424
+ containerport=$1
425
+ hostport=$2
426
+
427
+ if [ -z $hostport ]
428
+ then
429
+ ebstemplate=$( echo $ebstemplate | jq --arg containerPort $containerport --arg ebsportcount $ebsportcount ' .Ports[$ebsportcount |tonumber] |= .+ { ContainerPort: $containerPort }' )
430
+ else
431
+ ebstemplate=$( echo $ebstemplate | jq --arg hostPort $hostport --arg containerPort $containerport --arg ebsportcount $ebsportcount ' .Ports[$ebsportcount |tonumber] |= .+ { HostPort: $hostPort, ContainerPort: $containerPort }' )
432
+ fi
433
+
434
+ let ebsportcount=ebsportcount+1
435
+
436
+ }
437
+
421
438
422
439
EBS_push_docker_image () {
423
440
@@ -433,6 +450,26 @@ creating_updating_ebs_docker_json() {
433
450
sed -i.bak -e " s/@AWSS3AUTHBUCKET@/appirio-platform-$ENV_CONFIG /g" $EBS_TEMPLATE_SKELETON_FILE
434
451
rm ${EBS_TEMPLATE_SKELETON_FILE} .bak
435
452
453
+ # EBS Port Mapping
454
+ ebstemplate=$( cat $EBS_TEMPLATE_SKELETON_FILE )
455
+ if [ -z $AWS_EBS_PORTS ];
456
+ then
457
+ echo " No container port is defined. configuring default 8080 port"
458
+ ebsportmapping 8080
459
+ else
460
+ Buffer_portmap=$( echo $AWS_EBS_PORTS | sed ' s/,/ /g' )
461
+ for ebsportbuf in $Buffer_portmap ;
462
+ do
463
+ containerport=$( echo $ebsportbuf | cut -d ' :' -f 1 )
464
+ if [[ $ebsportbuf = * :* ]]; then
465
+ hostport=$( echo $ebsportbuf | cut -d ' :' -f 2 )
466
+ fi
467
+ ebsportmapping $containerport $hostport
468
+ done
469
+ fi
470
+ echo " $ebstemplate " > $EBS_TEMPLATE_SKELETON_FILE
471
+ log " port mapping updated"
472
+
436
473
if [ -z " $EBS_EB_EXTENSTION_LOCATION " ];
437
474
then
438
475
cat $EBS_TEMPLATE_SKELETON_FILE | sed -e " s/@IMAGE@/${IMG_WITH_EBS_TAG} /g" > $DOCKERRUN
0 commit comments