these are scripts for deploying Meteor apps to AWS Elastic Beanstalk. it is tested in linux and mac. (might not working in Windows)
all files need to be copied relatively to the Meteor app root.
- AWS has released a new Application Load Balancer. so setting dual port in ELB may not be needed someday when ALB come to Elastic Beanstalk.
- this is using
../build(from the Meteor app root) directory for building. default-*-names ineb.config.ymlandeb.packages.jsonneed to be customised.domain_nameineb.app.configneeds to be customised.- it generates and adds 512MB swap file in
/var/swapfile. - in installs
node-pre-gypnode package. - it copies
settings*.jsonfiles into deployment package. if you don't want, editscripts/cp-eb-scripts.shand useMETEOR_SETTING_FILEenv variable to set the file location.
- python
- pip
- aws-eb-cli
you can install pip and awsebcli by
$ curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python
$ sudo pip install awsebcli
AWS credentials needs to be installed.
it automatically asks when you eb init for the first time.
scripts/eb-deploy.sh
for the first time since the EB env created, it needs some manual settings for environment variables and Elastic Load Balancer.
since nginx configuration patching is executed during deployment, manual settings for Elastic Beanstalk environment should be done before deployment. but you can deploy anytime later, again and again, if you change settings manually.
you can add it in Elastic Beanstalk console, environment name, Configuration, Software Configuration.
-
DDP_DEFAULT_CONNECTION_URL
https://<domain_name>:8443/ -
MONGO_URL
mongodb://<user>:<pw>@<ip_addr>:27017/<db_name> -
PORT
8081 -
ROOT_URL
https://<domain_name>/ -
METEOR_SETTING_FILE (if it is a development)
./settings.dev.json
I am using HTTPS only and redirect HTTP to HTTPS,
so it use 80 and 443 port.
But Meteor needs sticky sessions for non websocket clients and
websocket needs TCP settings rather than HTTP setting for load balancers.
but AWS ELB does not support session stickness on TCP.
so you need to setup another port for websocket connection.
it will be port 8443 (ssl).
DDP connection will be set to :8443 by default by DDP_DEFAULT_CONNECTION_URL.
and Clients should change their DDP connection port to normal (443) for session stickness when websocket is not available.
if you arlaedy have ssl certificates, you can use it in ELB. or you could create it for free.
in the Load balacers tab in EC2 console,
select propriate Listeners tab.
and add SSL, 8443, TCP, 80.
and input SSL Certificate name and paste private key (.key) and public key(.crt).
and Save.
and then, go to Description tab and in the Security tab,
click sg-0xxxx link to go to VPC console.
there you need to add an Inbound Rules for 8443 port.
Edit, Add another rule,
select or input like HTTPS* (8443), TCP (6), 8443, 0.0.0.0/0
in the Elastic Beanstalk console, environment name, Configuration, Load balancer.
Turn on session stickiness at Sessions section with expiration period like 600
turn on HTTPS and select certificates input above.



AWS EB tools create zip file and upload it,
local time stamp (would be) archived.
and when it is uploaded and building node packages in the EC2 instance,
errors like followings
continuously occur.
probably because the time stamp is before time difference than UTC.
so I touched the timestamps by the build script and it is safe to set to before 24 hours because of summertime or so.