|
|
|
|
|
by mhio
1583 days ago
|
|
ip=$(curl https://api.ipify.org) tag_name="tmpip" tag_time=$(date -u '+%Y-%m-%dT%H:%M:%SZ') aws ec2 authorize-security-group-ingress --group-id sg-86169665d2453e4 --protocol tcp --port 22 --cidr "$ip/32" --tag-specifications "ResourceType=security-group-rule,Tags=[{Key=Name,Value=${tag_name}},{Key=added,Value=${tag_time}}]" The tag enables replacing the existing rule via tag Name, the further you go the easier it is to use the API SDKs |
|