0
votes

I'm using a step function to launch a batch job, how do I get the instance type that was ultimately used to process my job in a compute environment that is AWS managed? It doesn't look like this information is available with the CLI command describe-jobs.

1

1 Answers

1
votes

You can get at it through multiple CLI calls starting from the job-queue the job was submitted to; I'm using jq to filter the results down for this example.

NOTE: this assumes the EC2 instance is still up when each of the commands listed below is called.

Get the compute environment used:

aws batch describe-job-queues --job-queues YOUR_JOB_QUEUE | jq '.jobQueues | .[0] | .computeEnvironmentOrder | .[0] | .computeEnvironment'

Get the ECS cluster ARN used:

aws batch describe-compute-environments --compute-environment FROM_PREVIOUS | jq '.computeEnvironments | .[0] | .ecsClusterArn'

Get the ECS container instance

aws ecs list-container-instances --cluster FROM_PREVIOUS | jq '.containerInstanceArns | .[0]'

Get the instance data

aws ecs describe-container-instances --container-instances FROM_PREVIOUS1 --cluster FROM_PREVIOUS2 | jq '.containerInstances | .[0] | .attributes | .[] | select(.name=="ecs.instance-type") | .value'