APPLICATION_NAME=
DEPLOYMENT_GROUP=
DEPLOYMENT_CONFIG=CodeDeployDefault.OneAtATime
BUCKET=
PROFILE=default
PROJECT_NAME=$(cd $(dirname $0); pwd | perl -pe "s|.*/(.*?)/?|\1|" )
VERSION=$(date '+%Y%m%d%H%M%S')
echo "Project Name = $PROJECT_NAME"
FILENAME=${PROJECT_NAME}-${VERSION}.tar.gz
KEY=${PROJECT_NAME}/$FILENAME
tar zcf /tmp/${FILENAME} ./
aws --profile ${PROFILE} s3 cp /tmp/${FILENAME} s3://${BUCKET}/${KEY}
ETag=$(aws --profile ${PROFILE} s3api head-object --bucket ${BUCKET} --key ${KEY} | jq -r .ETag |perl -pe "s/\"(.*?)\"/\1/g")
echo "uploaded ETAG = ${ETag}"
aws --profile ${PROFILE} deploy \
create-deployment \
--description "deploy with shell. -- ${VERSION}" \
--application-name ${APPLICATION_NAME} \
--deployment-group-name ${DEPLOYMENT_GROUP} \
--deployment-config-name ${DEPLOYMENT_CONFIG} \
--s3-location '{ "bundleType":"tgz", "eTag": "'${ETag}'","bucket": "'${BUCKET}'", "key": "'${KEY}'"}'