Skip to main content

awacs

https://img.shields.io/pypi/v/awacs.svg https://travis-ci.org/cloudtools/awacs.png?branch=master https://img.shields.io/pypi/l/awacs.svg

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

Release files for awacs 2.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for awacs 2.6.0
File Size Uploaded
awacs-2.6.0.tar.gz 230.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for awacs 2.6.0
File Interpreter ABI Platform
awacs-2.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 668.0 kB

Release files / awacs-2.6.0.tar.gz

Download URL awacs-2.6.0.tar.gz
Size 230.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7919b15e2afd5f4f3e604544f81c5af8eb9ab0fa2481c528735489586791279f
BLAKE2b-256 checksum
How to use checksums
c8f0547d027ffbe3864996b689620426f1d9757f0d93adf363f73bb5d1a24ce0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release files / awacs-2.6.0-py3-none-any.whl

Download URL awacs-2.6.0-py3-none-any.whl
Size 437.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2b4feb94f04da6c7601285f9e76f9409ce12c97e94bce00589935599998a354
BLAKE2b-256 checksum
How to use checksums
fe96339a45f5280d1e87897ec9e1eaa08227aed9a4a68788339a4fe0d7141d4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.5

Release history Release notifications | RSS feed

This release

2.6.0 This release

2 release files

2.5.0

2 release files

2.4.1

2 release files

2.4.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.9.9

1 release file

0.9.8

1 release file

0.9.7

1 release file

0.9.6

1 release file

0.9.5

1 release file

0.9.4

1 release file

0.9.3

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.2

1 release file

0.7.1

1 release file

0.7.0

1 release file

0.6.2

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.2

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.0.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page