HI I am running a publicvm with a dynamic IP, and I want some security groups to point to the correct office IP everytime the IP change. I can get my office IP using https://wtfismyip.com/text. How do I take that new IP and edit the existing security groups using boto3? And I am planning to use fabric to do that
There is no way to edit the security group rules using Boto3. You have to delete the old rule and add a new rule. I haven't tried this one before but this what you have to do. Tweak it to your needs.
Removes one or more ingress rules from a security group
Adds one or more ingress rules to a security group
conn = boto3.client('ec2')
conn.authorize_security_group_ingress(GroupId=my_group_id,IpProtocol="tcp",CidrIp="new_ip/32",FromPort=443,ToPort=443)