Skip to content

Commit 30f02a3

Browse files
authored
Merge pull request #48 from dwc0011/handle-email-error-and-continue
Refactor to enable better error handling and future maintenance
2 parents 50f1851 + 2bec612 commit 30f02a3

29 files changed

Lines changed: 4472 additions & 475 deletions

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.0.0
2+
current_version = 3.0.0
33
commit = True
44
message = Bumps version to {new_version}
55
tag = False

.github/workflows/test-python.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Run pytest
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: pytest-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@61cb8a9741eeb8a550a1b8544337180c0fc8476b
23+
with:
24+
enable-cache: true
25+
cache-dependency-glob: "src/python/requirements-dev.txt"
26+
27+
- name: Install dependencies
28+
run: |
29+
uv venv
30+
uv pip install -r src/python/requirements-dev.txt
31+
32+
- name: Run tests
33+
run: uv run pytest tests/python/ -v

.pylintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MAIN]
2+
init-hook=import sys, os; sys.path.append(os.path.join(os.getcwd(), 'src', 'python'))

AUTHORS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Authors
2+
3+
* Plus3IT Maintainers of terraform-aws-tardigrade-iam-key-enforcer - projects@plus3it.com

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
### [3.0.0](https://github.com/plus3it/terraform-aws-tardigrade-iam-key-enforcer/releases/tag/3.0.0)
8+
9+
**Released**: 2026.01.20
10+
11+
**Summary**:
12+
13+
* Major refactoring of Python codebase for improved maintainability and robustness
14+
* Enhances error handling to continue processing remaining users when errors are encountered
15+
* Improves logging for better debugging and troubleshooting
16+
* Adds CLI mode for local testing and development
17+
* Removes unused Terraform variable `email_admin_report_subject`
18+
* Removes unused environment variable `EMAIL_ADMIN_REPORT_SUBJECT`
19+
* Tools
20+
* aws-lambda-powertools `3.24.0`
21+
* aws-assume-role-lib `2.10.0`
22+
* boto3 `1.42.30`
23+
724
### [2.0.0](https://github.com/plus3it/terraform-aws-tardigrade-iam-key-enforcer/releases/tag/2.0.0)
825

926
**Released**: 2026.01.02

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
# Add src/python to PYTHONPATH so pylint can find the modules
2+
export PYTHONPATH := $(PWD)/src/python:$(PYTHONPATH)
3+
14
include $(shell test -f .tardigrade-ci || curl -sSL -o .tardigrade-ci "https://raw.githubusercontent.com/plus3it/tardigrade-ci/master/bootstrap/Makefile.bootstrap"; echo .tardigrade-ci)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ The function audits each user in an account for access keys and determines how l
4343
| <a name="input_key_use_threshold"></a> [key\_use\_threshold](#input\_key\_use\_threshold) | Age at which unused keys should be deleted (e.g.30) | `number` | n/a | yes |
4444
| <a name="input_accounts"></a> [accounts](#input\_accounts) | List of account objects to create events for | <pre>list(object({<br/> account_name = string<br/> account_number = string<br/> role_name = optional(string) # deprecated<br/> armed = bool<br/> debug = optional(bool, false)<br/> email_user_enabled = bool<br/> email_targets = list(string)<br/> exempt_groups = list(string)<br/> schedule_expression = optional(string, "cron(0 1 ? * SUN *)")<br/><br/> }))</pre> | `[]` | no |
4545
| <a name="input_email_admin_report_enabled"></a> [email\_admin\_report\_enabled](#input\_email\_admin\_report\_enabled) | Used to enable or disable the SES emailed report | `bool` | `false` | no |
46-
| <a name="input_email_admin_report_subject"></a> [email\_admin\_report\_subject](#input\_email\_admin\_report\_subject) | Subject of the report email that is sent | `string` | `null` | no |
4746
| <a name="input_email_banner_message"></a> [email\_banner\_message](#input\_email\_banner\_message) | Messages that will be at the top of all emails sent to notify recipients of important information | `string` | `""` | no |
4847
| <a name="input_email_banner_message_color"></a> [email\_banner\_message\_color](#input\_email\_banner\_message\_color) | Color of email banner message, must be valid html color | `string` | `"red"` | no |
4948
| <a name="input_email_tag"></a> [email\_tag](#input\_email\_tag) | Tag to be placed on the IAM user that we can use to notify when their key is going to be disabled/deleted | `string` | `"keyenforcer:email"` | no |

main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ module "lambda" {
6363
environment_variables = {
6464
LOG_LEVEL = var.log_level
6565
EMAIL_ADMIN_REPORT_ENABLED = var.email_admin_report_enabled
66-
EMAIL_ADMIN_REPORT_SUBJECT = var.email_admin_report_subject
6766
EMAIL_SOURCE = var.email_source
6867
ADMIN_EMAIL = var.admin_email
6968
KEY_AGE_WARNING = var.key_age_warning

pytest.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[pytest]
2+
testpaths = tests/python
3+
python_files = test_*.py
4+
pythonpath = src/python
5+
addopts = -v --tb=short
6+
markers =
7+
smoke: mark test as smoke test
8+
regression: mark test as regression test
9+
slow: mark test as slow

ruff.toml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Line length and excludes chosen to match prior flake8 settings
2+
line-length = 88
3+
exclude = [
4+
".git",
5+
"__pycache__",
6+
".eggs",
7+
"*.egg",
8+
"build",
9+
"dist",
10+
"htmlcov",
11+
]
12+
13+
[lint]
14+
ignore = [
15+
"D107", # __init__ docstrings are documented at the class level to avoid duplication
16+
"D203", # Conflicts with D211 (no-blank-line-before-class). Project uses D211 style.
17+
"D212", # Conflicts with D213 (multi-line-summary-first-line). Project uses D213 style.
18+
"EXE001", # Only occurs in CI when source is restored as artifact (loses executable bit)
19+
"ANN", # 500+ missing type annotations across src/tests; keep ignored for now; see staged plan below
20+
]
21+
select = ["ALL"]
22+
23+
[lint.per-file-ignores]
24+
"tests/**" = ["S101", "S314", "SLF", "ARG", "PLR2004", "PLR0913", "INP001"]
25+
26+
# Prepare for future gradual enabling of ANN (flake8-annotations) with saner defaults
27+
[lint.flake8-annotations]
28+
# Don't require explicit "-> None" on __init__ (aligns with mypy default)
29+
mypy-init-return = true
30+
31+
# Allow using Any for *args/**kwargs without error
32+
allow-star-arg-any = true
33+
34+
# Don't flag unused conventional dummy args like _ or unused parameters in callbacks
35+
suppress-dummy-args = true
36+
37+
# Don't require explicit -> None on functions that implicitly return None
38+
suppress-none-returning = true

0 commit comments

Comments
 (0)