I'm running this command for getting the public IP of an EC2. It works as expected!
aws ec2 describe-instances --filters "Name=tag:Name,Values=EC2" --query 'Reservations[*].Instances[*].PublicIpAddress' --output text
I'm trying to use this value for running this command, so instead of XX.XX.XX.XX it has to be the value I get from ec2 describe-instances
ansible-playbook provisioning/site.yml -i inventory --ssh-common-args '-o "proxycommand ssh -W %h:%p -i Key.pem [email protected]"'
So I have my commands like this
IP=aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME_PREFIX*" --query 'Reservations[*].Instances[*].PublicIpAddress' --output text
export BASTION="ubuntu@${IP}"
ansible-playbook provisioning/site.yml -i inventory --ssh-common-args '-o "proxycommand ssh -W %h:%p -i Key.pem ${BASTION}"'
So not sure, how should I use that output, if you could help me please
IP=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME_PREFIX*" --query 'Reservations[*].Instances[*].PublicIpAddress' --output text)