You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you would like to persist data from your ECS containers, i.e. hosting databases like MySQL or MongoDB with Docker, you need to ensure that you can mount the data directory of the database in the container to volume that's not going to dissappear when your container or worse yet, the EC2 instance that hosts your containers, is restarted or scaled up or down for any reason.
This is a multi-step configuration -- easy mistakes are likely. Be patient! The pay-off will be worth it. Rudimentary knowledge and awareness of the AWS landscape is not necessarily required, but will make it easier to set things up.
Choose or create SSL cert (star is recommended: add *.yourdomain.com and yourdomain.com separately on the cert)
Select default ELB security policy
Next
Create prod-cluster specific security group only allowing port 80 and 443 inbound
Next
New target group, name: app-name
Health-checks: Keep default "/" if serving a website on HTTP, but if deploying an API and/or redirecting all HTTP calls to HTTPS, ensure your app defines a custom route that is not redirected to HTTPS. On HTTP server GET "/healthCheck" return simple 200 message saying "I'm healthy" -- verify that this does not redirect to HTTPS, otherwise lot's of pain and suffering will occur. Health checks on AWS will fail.
Next:Review, then Create
Create Service
Go to Amazon ECS
Clusters -> Select "prod-ecs-cluster"
Task Definition: app-name-task from before
Service name: app-name
No of tasks: 2, min healthy: 100, max healthy: 200 for highly available blue/green deployment setup
Configure ELB
6.1. Application Load Balancer
6.2. ecsServiceRole
6.3. Select app-name-prod-elb from before
6.4. Select app-name:0:3000 container from before
6.5. Add to ELB
6.6. Target Group Name: app-name from before
6.7. Save
Create Service
View Service
Verify information
Build image with npm run image:build
Publish and release image with npm run aws:publish
On the Service Events tabs keep an eye on health check errors
Go to the ELB DNS address and see if your app works.
If you used Route 53 to connect your domain with your ELB or through your own DNS provider, then go to the URL and see if things work.
Troubleshooting
ELB DNS works, but URL doesn't? Your DNS configuration is wrong.
ELB DNS doesn't work. Then check the health of your ECS Service, see step 3 below.
Go to ECS -> Your Cluster -> click on Your Service and switch to the events tab:
If you don't see service your-app has reached a steady state. then your container is having trouble starting or AWS is failing to perform a health check.
To see what's wrong with your container, go to the Cloudwatch Logs you setup earlier and you'll be able to see the console logs of your application.
Service is healthy, logs look fine. Things still don't work? Then re-check security group port rules and target group port rules and any AWS IAM security role you may have setup or may be overriding some default behavior that hasn't been covered.