Created
November 5, 2019 22:58
-
-
Save MooreDerek/6fb37560305aa4519d161b33ba8f301c to your computer and use it in GitHub Desktop.
Get the Public IP for a Fargate task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CLUSTER=<cluster> | |
SERVCICE=<service> | |
# Make sure that the Fargate has aactually started | |
aws ecs wait services-stable --cluster ${CLUSTER} --services ${SERVICE} | |
TASK_ARN=`aws ecs list-tasks --cluster ${CLUSTER} --service-name ${SERVICE} | jq -r '.taskArns[] '` | |
ENI_ID=`aws ecs describe-tasks --cluster ${CLUSTER} --task "${TASK_ARN}" | \ | |
jq -r '.tasks[] | .attachments[] | .details[] | select(.name=="networkInterfaceId") | .value'` | |
PUBLIC_IP=`aws ec2 describe-network-interfaces --network-interface-ids ${ENI_ID} | \ | |
jq -r '.NetworkInterfaces[] | .Association | .PublicIp'` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment