AWS Access Policy Language creation library
Project description
About
awacs - Amazon Web Access Control Subsystem
The awacs library allows for easier creation of AWS Access Policy Language JSON by writing Python code to describe the AWS policies. To facilitate catching policy format or JSON errors early the library has property and type checking built into the classes.
NOTE: The old awacs.aws.Policy object is going to be deprecated in the future, in preference for the awacs.aws.PolicyDocument class. This is due to confusion that arises between the old object and troposphere.iam.Policy objects.
Installation
awacs can be installed using the pip distribution system for python by issuing:
$ pip install awacs
Alternatively, you can run use setup.py to install by cloning this repository and issuing:
$ python setup.py install
Examples
An example to use this comes from the AWS IAM documentation. This shows creating policy attached to an Amazon S3 bucket:
from awacs.aws import Action, Allow, PolicyDocument, Principal, Statement
from awacs.iam import ARN as IAM_ARN
from awacs.s3 import ARN as S3_ARN
account = "123456789012"
user = "user/Bob"
pd = PolicyDocument(
Version="2012-10-17",
Id="S3-Account-Permissions",
Statement=[
Statement(
Sid="1",
Effect=Allow,
Principal=Principal("AWS", [IAM_ARN(user, '', account)]),
Action=[Action("s3", "*")],
Resource=[S3_ARN("my_corporate_bucket/*"),],
),
],
)
print(pd.to_json())
would produce this json policy:
{
"Id": "S3-Account-Permissions",
"Statement": [
{
"Action": [
"s3:*"
],
"Effect": "Allow",
"Principal": [
{
"AWS": [
"arn:aws:iam::123456789012:user/Bob"
]
}
],
"Resource": [
"arn:aws:s3:::my_corporate_bucket/*"
],
"Sid": "1"
}
],
"Version": "2012-10-17"
}
Community
We have a google group, cloudtools-dev, where you can ask questions and engage with the cloudtools/awacs community. Issues & pull requests are always welcome!
Contributing new actions
To update actions there is a generator tool which will scrape policies from AWS’s documentation resource and auto-generate new files. The following commands can be run (with Python 3.7+) to update the repo:
$ python3 -m pip install -r scrape/requirements.txt
$ python3 -m pip install .
$ python3 ./scrape/scrape.py
$ git diff
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file awacs-2.4.1.tar.gz
.
File metadata
- Download URL: awacs-2.4.1.tar.gz
- Upload date:
- Size: 183.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0da356ae56374ea872c6cdb00946bb22e9cd817c3f3ad6b008019e3a45d8040 |
|
MD5 | 6ad97f54f1ca3b3fefdca791cf2ed736 |
|
BLAKE2b-256 | 3ffca6c46e95967982836c69ac45698e113f3aea52ca35cd7f7ffa792ba7d2f9 |
File details
Details for the file awacs-2.4.1-py3-none-any.whl
.
File metadata
- Download URL: awacs-2.4.1-py3-none-any.whl
- Upload date:
- Size: 354.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c54470f6a2d45de1ec2907417b46f791e44bf6e7d2d5a581ca1d5153b3ea9e6 |
|
MD5 | 86807c2ca8dc45776e76a9d261c8a5e2 |
|
BLAKE2b-256 | 0f5a533a0406d0de3662cb3ea70dc66b0a5f671b6ee00afabf2876c6412c68a0 |