title |
---|
How It Works |
The process that I outline in the [Why]({% link _docs/why.md %}) about clicking around is close to the logic that actually takes place in the tool. Here's an overview of what actually happens internally for those who are interested.
Steps:
- list-tasks: list all the tasks for their task_arns (scoped to service). this is all tasks on the service. We already know the service name!
- describe-tasks: Using the task_arns from list-tasks. This will provide the container instance scoped the service since list-tasks was scoped to service. Keep the task arn for step 7. Also describe-task-definition and capture env vars and image for step 8b.
- describe-container-instances: Using container_instance_arn from step 2. This will provide the instance_id to ssh into.
- ec2 describe-instances to get the dns name or IP address.
- Copy over files with required info over to the server with scp.
- ssh into the machine with IP address.
- Use the ecs metadata and pass it the task_arn from step 2. This will provide the map to the container id.
- Run docker command
- docker exec -ti CONTAINER_ID
options[:command]
- docker run -ti IMAGE
options[:command]
- docker exec -ti CONTAINER_ID
In order to pass info over from your local machine to the container instance a file is generated and copied in step 5. The file contains:
- Options all the way from the original cli call like command to run. This is in json form. A bash script is also copied.
- Bash script gets the container id using the task_arn. It also will run the docker exec or run command.
- So bash script does steps 7 and 8.1 or 8.2.
NOTE: I thought it would be possible to map the container instance info from aws ecs describe-services
but it is not possible. But we can map to the container instance DNS name starting from aws ecs list-tasks
.
Pro tip: Use the <- and -> arrow keys to move back and forward.