How to fetch the external link of aws ecs task running which has the public ip of container instance and port of the task running?
I am managing task/service execution from cli and would like to fetch the external link which is shown in the aws UI from aws cli. I tried describe-tasks command of aws cli but it doesn't return the public IP address of the instance the task is running on.
Is there a way to fetch the same from aws cli?
Thanks in advance!
This is quite the pain in the neck, but it will do what you want:
aws ecs list-tasks --cluster mycluster --service-name my-service-name
aws ecs describe-tasks --cluster mycluster --tasks arn:aws:ecs:us-east-1:999999999999:task/ad0ba3e9-ac3b-4a4c-a1af-de3e06f46dfa
aws ecs describe-container-instances --cluster mycluster --container-instances arn:aws:ecs:us-east-1:999999999999:container-instance/707e5193-51e3-454b-ba09-9745c5d7f527
aws ec2 describe-instances --instance-ids i-c91aee40d92c23b3c
^^^^ NOT ECS
The output of this command should include the private IP of the EC2 instance. This IP + previously computed port should correspond to the external link from the web UI.
NOTE: Data has been anonymized, but should still LOOK like what you can expect to see. Also I omitted AWS region and profile params, which I have set to defaults using environment variables.