如何使用 BOTO3 更改 aws 安全组

How do I change the aws security groups using BOTO3

嗨,我是 运行 具有动态 IP 的 publicvm,我希望一些安全组在每次 IP 更改时都指向正确的办公室 IP。我可以使用 https://wtfismyip.com/text 获取我的办公室 IP。我如何获取新 IP 并使用 boto3 编辑现有安全组?我打算使用织物来做到这一点

无法使用 Boto3 编辑安全组规则。您必须删除旧规则并添加新规则。我以前没有尝试过这个,但这是你必须做的。根据您的需要进行调整。

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)