Amazon web services 如何使用BOTO3更改aws安全组

Amazon web services 如何使用BOTO3更改aws安全组,amazon-web-services,fabric,boto3,aws-security-group,Amazon Web Services,Fabric,Boto3,Aws Security Group,您好,我正在运行一个具有动态IP的publicvm,每次IP更改时,我希望一些安全组指向正确的office IP。我可以使用我的办公室IP。如何使用boto3获取新IP并编辑现有安全组?我计划使用fabric来实现这一点无法使用Boto3编辑安全组规则。您必须删除旧规则并添加新规则。我以前没试过这个,但这是你必须做的。根据你的需要调整它 conn = boto3.client('ec2') conn.authorize_security_group_ingress(Group

您好,我正在运行一个具有动态IP的publicvm,每次IP更改时,我希望一些安全组指向正确的office IP。我可以使用我的办公室IP。如何使用boto3获取新IP并编辑现有安全组?我计划使用fabric来实现这一点

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

    conn = boto3.client('ec2')
    conn.authorize_security_group_ingress(GroupId=my_group_id,IpProtocol="tcp",CidrIp="new_ip/32",FromPort=443,ToPort=443)