【问题标题】:boto3 equivalent to gather all aws security groupsboto3 相当于收集所有 aws 安全组
【发布时间】:2016-11-30 16:47:54
【问题描述】:

使用旧版本的 boto,您可以使用以下内容将所有安全组拉入 aws 帐户:

import boto.ec2
conn = boto3.connect_to_region("us-east-1")
groups = conn.get_all_security_groups()

但是对于 boto3,文档并不清楚如何执行相同的操作。这里有很多参考资料涉及使用新的 boto3 包更改策略,但没有列出所有安全组和策略的机制。

这个操作有新方法吗?

【问题讨论】:

    标签: amazon-web-services aws-sdk boto3


    【解决方案1】:

    Boto3 提供了一个低级别的 client,它的方法名称几乎与您可以在 AWS API 中找到的相同。
    因此,要获取(或在通常称为 describe 的 aws 上下文中),您可以执行以下操作:

    import boto3
    client = boto3.client('ec2')
    client.describe_security_groups()
    

    更多信息在这里:http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Client.describe_security_groups

    【讨论】:

    • 就是这样!谢谢!!
    猜你喜欢
    • 2018-10-13
    • 2017-08-10
    • 2017-03-08
    • 2016-04-11
    • 2015-10-16
    • 2015-09-02
    • 2021-03-25
    • 1970-01-01
    • 2017-04-29
    相关资源
    最近更新 更多