@@ -45,7 +45,7 @@ APP_IMAGE_NAME=""
4545DOCKERRUN=" Dockerrun.aws.json"
4646# EBS_EB_EXTENSTION_LOCATION=""
4747IMG_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"
4949EBS_APPLICATION_NAME=" "
5050EBS_APPVER=" "
5151EBS_TAG=" "
@@ -58,7 +58,8 @@ EBS_TEMPLATE_FILE_NAME=""
5858# AWS_EBS_EB_DOCKERRUN_TEMPLATE_LOCATION=$(eval "echo \$${ENV}_AWS_EBS_EB_DOCKERRUN_TEMPLATE_LOCATION")
5959# AWS_EBS_DOCKERRUN_TEMPLATE=$(eval "echo \$${ENV}_AWS_EBS_DOCKERRUN_TEMPLATE")
6060# AWS_S3_KEY_LOCATION=""
61-
61+ ebsportcount=0
62+ ebstemplate=" "
6263# variable for cloud front
6364# AWS_S3_BUCKET=""
6465# AWS_S3_SOURCE_SYNC_PATH=""
@@ -418,6 +419,22 @@ validate_update_loggroup()
418419}
419420# EBS integration
420421
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+
421438
422439EBS_push_docker_image () {
423440
@@ -433,6 +450,26 @@ creating_updating_ebs_docker_json() {
433450 sed -i.bak -e " s/@AWSS3AUTHBUCKET@/appirio-platform-$ENV_CONFIG /g" $EBS_TEMPLATE_SKELETON_FILE
434451 rm ${EBS_TEMPLATE_SKELETON_FILE} .bak
435452
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+
436473 if [ -z " $EBS_EB_EXTENSTION_LOCATION " ];
437474 then
438475 cat $EBS_TEMPLATE_SKELETON_FILE | sed -e " s/@IMAGE@/${IMG_WITH_EBS_TAG} /g" > $DOCKERRUN
0 commit comments