cd ~/environment/ecsdemo-frontend/
ecs-cli local create --task-def-remote $(aws ecs list-task-definitions | jq -r '.taskDefinitionArns[] | select(contains ("frontend"))')
cat docker-compose.ecs-local.yml
sed -i 's/published: 3000/published: 8080/g' docker-compose.ecs-local.yml
# this command downloads the existing task definition and extracts the containerdefinition name to be used for service discovery
nodeservicename=$(aws ecs describe-task-definition --task-definition $(aws ecs list-task-definitions | jq -r '.taskDefinitionArns[] | select(contains ("nodejs"))') | jq -r .taskDefinition.containerDefinitions[0].name)
crystalservicename=$(aws ecs describe-task-definition --task-definition $(aws ecs list-task-definitions | jq -r '.taskDefinitionArns[] | select(contains ("crystal"))') | jq -r .taskDefinition.containerDefinitions[0].name)
# now that we know our service discovery names, we can substitute them into the docker-compose file
sed -i "s/ecsdemo-nodejs.service:3000/${nodeservicename}:3000/g" docker-compose.ecs-local.yml
sed -i "s/ecsdemo-crystal.service:3000/${crystalservicename}:3000/g" docker-compose.ecs-local.yml
ecs-cli local up
ecs-cli local ps --all
curl localhost:8080/health
Using Cloud9, select Preview
–> Preview Running Application
at the top
A new tab will open, remove the ‘/’ at the end and append :8080
to the url in the Cloud9 browser and hit enter.
Finally, select the box next in the Cloud9 browser that will open the url in another tab in your local browser. It looks like this: