cloudtools / awacs

Python library for AWS Access Policy Language creation
BSD 2-Clause "Simplified" License
395 stars 102 forks source link

Allow a list of Principals as property of the Statement class #92

Closed christiangrenzel closed 6 years ago

christiangrenzel commented 6 years ago

Hi. The Statement class only allows a single principal as argument. When a list of principals has the same statement, I have to repeat the statement for each principal instead of creating a single statement with a list of principals. Would be cleaner to pass a list of principals and have a single statement for a list of principals. Thanks!

markpeek commented 6 years ago

Do you mean something like this?

>>> from awacs.aws import Principal
>>> p = Principal("AWS", ["arn:aws:iam::AWS-account-ID1:root", "arn:aws:iam::AWS-account-ID2:root"])
>>> print p.data
{'AWS': ['arn:aws:iam::AWS-account-ID1:root', 'arn:aws:iam::AWS-account-ID2:root']}
>>> print p.to_json()
{
    "AWS": [
        "arn:aws:iam::AWS-account-ID1:root",
        "arn:aws:iam::AWS-account-ID2:root"
    ]
}

If so, it already supports it. If not, please give more details on what you'd like to see from awacs and the JSON output.

christiangrenzel commented 6 years ago

Omg yes! that's what I need. Sorry for not seeing this.