Home > Software engineering >  How Can I add description to security group from AWS CLI
How Can I add description to security group from AWS CLI

Time:05-20

I am trying to add the IP address to a security group from CLI and I am able to do so, however I am trying to add the description . Can someone support me to know how to add description.

I am trying below way:

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

seems the exact command for that to work is as below, but how to pass IP in the same command

The below command is working fine, but is there a way I can pass my cidr using curl? I tried same way as in question but not going trough

aws ec2 authorize-security-group-ingress \ 
--group-id sg-12345678 \ 
--ip-permissions IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges='[{CidrIp=1.1.1.1/32,Description="Testing"}]' --profile xyz

CodePudding user response:

aws ec2 authorize-security-group-ingress \
    --group-id sg-123456778 \
    --ip-permissions "IpProtocol=tcp,FromPort=22,ToPort=22,IpRanges=[{CidrIp=`curl -s https://checkip.amazonaws.com`/32,Description=\"testing\"}]"
  • Related