IP address from a Fargate task

From wikieduonline
Revision as of 10:30, 24 April 2023 by Welcome (talk | contribs) (Created page with "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 "${TA...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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"



Advertising: