Difference between revisions of "IP address from a Fargate task"

From wikieduonline
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
  [[SERVICE_NAME]]="my-service"
 
  [[SERVICE_NAME]]="my-service"
 
   
 
   
  TASK_ARN=$([[aws ecs list-tasks]] --service-name "$SERVICE_NAME" --query 'taskArns[0]' --output text)
+
  TASK_ARN=$([[aws ecs list-tasks --service-name]] "$SERVICE_NAME" --query 'taskArns[0]' --output text)
 
  TASK_DETAILS=$([[aws ecs describe-tasks]] --task "${TASK_ARN}" --query 'tasks[0].attachments[0].details')
 
  TASK_DETAILS=$([[aws ecs describe-tasks]] --task "${TASK_ARN}" --query 'tasks[0].attachments[0].details')
 
  ENI=$(echo $TASK_DETAILS | jq -r '.[] | select(.name=="networkInterfaceId").value')
 
  ENI=$(echo $TASK_DETAILS | jq -r '.[] | select(.name=="networkInterfaceId").value')
Line 11: Line 11:
  
  
 +
List services:
 +
for CLUSTER in $(aws ecs list-clusters | grep arn  | cut -d'"' -f2 | cut -d "/" -f2); do
 +
    [[aws ecs list-services --cluster]] $CLUSTER | grep arn | cut -d'"' -f2 | cut -d "/" -f3
 +
done
  
 +
 +
== Related ==
 +
{{list all services}}
 +
 +
[[aws ecs]] list-services --cluster [[your-cluster]]
 +
 +
 +
== See also ==
 
* {{IP}}
 
* {{IP}}
 
* {{Fargate}}
 
* {{Fargate}}

Latest revision as of 10:53, 30 May 2023

SERVICE_NAME="my-service"

TASK_ARN=$(aws ecs list-tasks --service-name "$SERVICE_NAME" --query 'taskArns[0]' --output text)
TASK_DETAILS=$(aws ecs describe-tasks --task "${TASK_ARN}" --query 'tasks[0].attachments[0].details')
ENI=$(echo $TASK_DETAILS | jq -r '.[] | select(.name=="networkInterfaceId").value')
IP=$(aws ec2 describe-network-interfaces --network-interface-ids "${ENI}" --query 
'NetworkInterfaces[0].Association.PublicIp' --output text)

echo "$IP"


List services:

for CLUSTER in $(aws ecs list-clusters | grep arn  | cut -d'"' -f2 | cut -d "/" -f2); do 
    aws ecs list-services --cluster $CLUSTER | grep arn | cut -d'"' -f2 | cut -d "/" -f3
done


Related[edit]

 for CLUSTER in $(aws ecs list-clusters | grep arn  | cut -d'"' -f2 | cut -d "/" -f2); do 
     aws ecs list-services --cluster $CLUSTER | grep arn | cut -d'"' -f2 | cut -d "/" -f3
done
aws ecs list-services --cluster your-cluster


See also[edit]

Advertising: