Amazon Elastic Beanstalk の環境構築を行いつつアプリケーションのデプロイを行うスクリプト

#!/bin/bash

ACCOUNT=
APP_NAME=
ENV_NAME=
CONFIG_NAME=
WAR_NAME=
REGION=ap-northeast-1

cd `dirname $0`

date=`date +%Y%m%d%H%M`

aws s3 cp target/${WAR_NAME}.war s3://elasticbeanstalk-${REGION}-${ACCOUNT}/${APP_NAME}/${WAR_NAME}-${date}.war
aws elasticbeanstalk create-application-version --application-name ${APP_NAME} --version-label ${WAR_NAME}-${date} --source-bundle S3Bucket=elasticbeanstalk-${REGION}-${ACCOUNT},S3Key=${APP_NAME}/${WAR_NAME}-${date}.war --region ${REGION}
cd target/${WAR_NAME}
eb create ${ENV_NAME}-${date} --version ${WAR_NAME}-${date} --cfg ${CONFIG_NAME} -c ${APP_NAME}-${date} --scale 2
cd -