使用 Boto3 修改给定 EC2 安全组的规则 [英] Modifying rules for a given EC2 security group with Boto3

查看:31
本文介绍了使用 Boto3 修改给定 EC2 安全组的规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近一直致力于以编程方式向 EC2 服务器上的安全组添加和删除入口规则.但是,我现在似乎遇到了一些障碍.

I have recently been working on programatically adding and removing ingress rules to security groups on my EC2 server. However, I now seem to have hit a bit of a wall.

我希望能够通过 Python 脚本修改现有规则,但我找不到有关 Boto3 文档的任何指导.

I would like to be able to modify existing rules through a python script, but I haven't been able to find any guidance on the Boto3 docs.

有什么办法可以做到吗?

Is there any way in which this can be done?

谢谢

推荐答案

参见 Boto3:SecurityGroup

SG 中没有用于修改规则的 API.您必须先撤销规则,然后使用授权添加具有修改参数的规则.该链接还包含代码片段.

There is no API to modify a rule in SG. You have to revoke the rule first and then add the rule with the modified parameters using authorize. The link also has code snippets.

  • authorize_egress()
  • authorize_ingress()
  • revoke_egress()
  • revoke_ingress()

这篇关于使用 Boto3 修改给定 EC2 安全组的规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆