简体   繁体   中英

How can I add an IP address in a AWS CLI with out exporting

I am running below command to ingress in aws-cli, it is working fine if I provide an IP address, but I want it to know the IP and pass it. I was trying something like below but it is not helping

aws ec2 authorize-security-group-ingress --group-id sg-123456778 --protocol tcp --port 22 --cidr echo "$(curl https://checkip.amazonaws.com)/32" --profile xyzzy

If I am doing below then it works but I want it to be done by above way.

IP=`echo "$(curl https://checkip.amazonaws.com)/32"`
aws ec2 authorize-security-group-ingress --group-id sg-123456778 --protocol tcp --port 22 --cidr $IP --profile xyzzy

Use -s with curl .

Try this:

aws ec2 authorize-security-group-ingress --group-id sg-123456778 --protocol tcp --port 22 --cidr $(echo "$(curl -s https://checkip.amazonaws.com)/32") --profile xyzzy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM