Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORP/KPI read cloudtrail events #67

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## v4.10.0

- Add read Cloudtrail event permission

## v4.9.0

- Add `external_iam_role` to allow Airflow Pulumi tests to pass
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ kms:
- test_kms_key_arn

bedrock: true

cloudtrail_lookup_events: true
```

Whilst the example json (`iam_config.json`) looks like this:
Expand All @@ -100,7 +102,8 @@ Whilst the example json (`iam_config.json`) looks like this:
]
},
"kms": ["test_kms_key_arn"],
"bedrock": true
"bedrock": true,
"cloudtrail_lookup_events": true
}
```

Expand Down Expand Up @@ -129,6 +132,8 @@ Whilst the example json (`iam_config.json`) looks like this:

- **bedrock:** Boolean; must be set to `true` to allow role to interact with Amazon Bedrock. If `false` or absent role will not be able to interact with Amazon Bedrock.

- **cloudtrail_lookup_events** Boolean; must be set to `true` to allow role to read Amazon CloudTrail events. If `false` or absent role will not be able to read Amazon Cloudtrail events.

## How to update

When updating IAM builder, make sure to change the version number in `pyproject.toml` and describe the change in `CHANGELOG.md`.
Expand Down
3 changes: 3 additions & 0 deletions iam_builder/iam_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,7 @@ def build_iam_policy(config: dict) -> dict: # noqa: C901
if "bedrock" in config and config["bedrock"]:
iam["Statement"].extend(iam_lookup["bedrock"])

if "cloudtrail_lookup_events" in config:
iam["Statement"].extend(iam_lookup["cloudtrail_lookup_events"])

return iam
4 changes: 4 additions & 0 deletions iam_builder/schemas/iam_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
"description": "bedrock must be set to true to allow role to interact with Amazon Bedrock.",
"type": "boolean"
},
"cloudtrail_lookup_events": {
"description": "cloudtrail_lookup_events must be set to true to allow cloudtrail lookup",
"type": "boolean"
},
"role_duration_seconds":{
"description": "Max duration role can be assumed for in seconds",
"type": "integer"
Expand Down
10 changes: 10 additions & 0 deletions iam_builder/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@
}
}
}
],
"cloudtrail_lookup_events": [
{
"Sid": "allowLookup",
"Effect": "Allow",
"Action": [
"cloudtrail:LookupEvents"
],
"Resource": ["*"]
}
]
}

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iam_builder"
version = "4.9.0"
version = "4.10.0"
description = "A lil python package to generate iam policies"
authors = ["Karik Isichei <[email protected]>"]
license = "MIT"
Expand Down
13 changes: 13 additions & 0 deletions tests/expected_policy/cloudtrail_lookup_events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "allowLookup",
"Effect": "Allow",
"Action": [
"cloudtrail:LookupEvents"
],
"Resource": ["*"]
}
]
}
1 change: 1 addition & 0 deletions tests/test_config/cloudtrail_lookup_events.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloudtrail_lookup_events: true
3 changes: 2 additions & 1 deletion tests/test_iam_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class TestConfigOutputs(unittest.TestCase):
"glue_job",
"all_config",
"secrets",
"secrets_readwrite"
"secrets_readwrite",
"cloudtrail_lookup_events"
]
)
def test_config_output(self, config_name):
Expand Down
Loading