driftwatch-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: driftwatch-cli
3
+ Version: 0.1.0
4
+ Summary: CLI tool that detects Terraform infrastructure drift against live AWS, explains it with AI, and guides remediation.
5
+ Author: Nitin Gupta
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/hastagnitin/driftwatch
8
+ Project-URL: Repository, https://github.com/hastagnitin/driftwatch
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: boto3>=1.34.0
13
+ Requires-Dist: typer>=0.9.0
14
+ Requires-Dist: groq>=0.4.0
15
+ Requires-Dist: python-telegram-bot>=20.0
16
+ Requires-Dist: psycopg2-binary>=2.9.0
17
+ Requires-Dist: requests>=2.31.0
18
+ Requires-Dist: python-dotenv>=1.0.0
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
21
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
22
+ Requires-Dist: moto[all]>=5.0.0; extra == "dev"
23
+ Requires-Dist: build; extra == "dev"
24
+ Requires-Dist: twine; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # DriftWatch ๐Ÿ›ก๏ธ
28
+
29
+ **DriftWatch** is a production-ready CLI tool and automation engine that detects Terraform infrastructure drift against live AWS environments, explains the security and reliability impact using AI, and safely guides remediation.
30
+
31
+ ---
32
+
33
+ ## ๐Ÿš€ Key Features
34
+
35
+ - **Multi-Resource Drift Detection**: Continuously monitors and compares EC2 instances, S3 buckets, Security Groups, RDS databases, Lambda functions, and IAM roles against your Terraform state.
36
+ - **Data-Driven Severity Scoring**: Evaluates changes dynamically at the attribute level (e.g. security group open ports vs description updates) to classify drifts as `CRITICAL`, `HIGH`, `MEDIUM`, or `LOW`.
37
+ - **AI-Powered Risk Summaries**: Integrates with LLMs to provide plain-English security analysis and compliance impact assessments.
38
+ - **Deterministic IaC Remediation**: Recommends safe, template-generated `terraform import` and `terraform apply` commands rather than hallucinated AI outputs.
39
+ - **Guarded Auto-Remediation**: Pre-flight validation checks for EC2 (EBS verification, Spot skip, running state), RDS maintenance-window defaults, and explicit interactive confirmations.
40
+ - **Multi-Channel Alerting**: Instant notifications via Telegram, Slack, and Email.
41
+ - **CI/CD Quality Gate**: Built-in GitHub Actions integration to enforce zero-tolerance drift policies in pull requests.
42
+
43
+ ---
44
+
45
+ ## ๐Ÿ›๏ธ Architecture Overview
46
+
47
+ ```
48
+ driftwatch/
49
+ โ”œโ”€โ”€ drift_engine/ # Core drift detection & reconciliation engine
50
+ โ”‚ โ”œโ”€โ”€ aws_client.py # Live AWS resource discovery (boto3)
51
+ โ”‚ โ”œโ”€โ”€ core.py # Diff evaluation & data-driven severity engine
52
+ โ”‚ โ”œโ”€โ”€ database.py # PostgreSQL scan history recorder
53
+ โ”‚ โ”œโ”€โ”€ explain.py # AI risk summaries & deterministic IaC templates
54
+ โ”‚ โ”œโ”€โ”€ models.py # Data models & attribute severity tables
55
+ โ”‚ โ”œโ”€โ”€ notifications.py # Alert dispatcher (Telegram, Slack, Email)
56
+ โ”‚ โ”œโ”€โ”€ remediation.py # Guarded auto-remediation handlers
57
+ โ”‚ โ””โ”€โ”€ tf_parser.py # Terraform state JSON parser
58
+ โ”œโ”€โ”€ driftwatch/ # CLI Entrypoint (Typer)
59
+ โ”‚ โ””โ”€โ”€ cli.py # Command definitions: scan, explain, remediate
60
+ โ”œโ”€โ”€ terraform/ # Example infrastructure and state configuration
61
+ โ”œโ”€โ”€ kubernetes/ # Kubernetes CronJob deployment
62
+ โ””โ”€โ”€ tests/ # Comprehensive unit tests with moto AWS mocks
63
+ ```
64
+
65
+ ---
66
+
67
+ ## ๐Ÿ“‹ Prerequisites
68
+
69
+ - **Python**: `>= 3.10`
70
+ - **AWS Credentials**: Configured via environment variables, IAM roles, or AWS CLI credentials (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_DEFAULT_REGION`).
71
+ - **Terraform State File**: Local JSON state or remote state (`terraform.tfstate`).
72
+ - **PostgreSQL** *(Optional)*: For persistent scan audit history.
73
+ - **Groq API Key** *(Optional)*: `GROQ_API_KEY` for AI risk explanations.
74
+
75
+ ---
76
+
77
+ ## ๐Ÿ“ฆ Installation
78
+
79
+ ### From Source (Local Development)
80
+ ```bash
81
+ git clone https://github.com/hastagnitin/driftwatch.git
82
+ cd driftwatch
83
+ pip install -e .[dev]
84
+ ```
85
+
86
+ ---
87
+
88
+ ## โš™๏ธ Configuration
89
+
90
+ Create a `.env` file in the root directory:
91
+
92
+ ```env
93
+ AWS_DEFAULT_REGION=ap-south-1
94
+ TF_STATE_PATH=terraform/terraform.tfstate
95
+
96
+ # Optional: AI Risk Summaries
97
+ GROQ_API_KEY=your_groq_api_key
98
+
99
+ # Optional: Notifications
100
+ SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
101
+ TELEGRAM_BOT_TOKEN=your_telegram_bot_token
102
+ TELEGRAM_CHAT_ID=your_telegram_chat_id
103
+
104
+ # Optional: PostgreSQL Database
105
+ DB_HOST=localhost
106
+ DB_PORT=5432
107
+ DB_NAME=driftwatch
108
+ DB_USER=postgres
109
+ DB_PASSWORD=your_db_password
110
+ ```
111
+
112
+ ---
113
+
114
+ ## ๐Ÿ’ป Usage & CLI Commands
115
+
116
+ ### 1. Scan for Drift
117
+ Scan live AWS infrastructure against your Terraform state:
118
+ ```bash
119
+ # Basic scan
120
+ driftwatch scan --region ap-south-1 --state terraform/terraform.tfstate
121
+
122
+ # Enforce CI Gate (fails build if CRITICAL drift is found)
123
+ driftwatch scan --region ap-south-1 --fail-on CRITICAL
124
+ ```
125
+
126
+ ### 2. Explain Drift
127
+ Generate AI risk analysis and deterministic IaC fix recommendations:
128
+ ```bash
129
+ driftwatch explain sg-0123456789abcdef0 --region ap-south-1
130
+ ```
131
+
132
+ ### 3. Remediate Drift
133
+ Safely remediate drifted resources back to IaC specifications:
134
+ ```bash
135
+ # Dry run mode (default)
136
+ driftwatch remediate sg-0123456789abcdef0 --region ap-south-1 --dry-run
137
+
138
+ # Apply mode with interactive confirmation
139
+ driftwatch remediate sg-0123456789abcdef0 --region ap-south-1 --apply
140
+ ```
141
+
142
+ ---
143
+
144
+ ## โš ๏ธ Security & Safety Guidelines
145
+
146
+ > [!WARNING]
147
+ > **Auto-Remediation Safety**:
148
+ > - Automated drift remediation is intended for **Development** and **Staging** environments.
149
+ > - In **Production**, DriftWatch enforces manual confirmation prompts (`confirm_action()`) and recommends template-generated `terraform apply` / `terraform import` workflows.
150
+ > - RDS modifications default to maintenance windows (`ApplyImmediately=False`) to avoid unplanned reboots.
151
+
152
+ ---
153
+
154
+ ## ๐Ÿงช Testing
155
+
156
+ Run the test suite with test coverage:
157
+ ```bash
158
+ pytest tests/ -v --cov=drift_engine --cov=driftwatch --cov-report=term-missing
159
+ ```
160
+
161
+ ---
162
+
163
+ ## ๐Ÿ“„ License
164
+
165
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,17 @@
1
+ drift_engine/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ drift_engine/aws_client.py,sha256=-HlFZBskOkKk9Itug6Z8WIO4-Um_0efXACdZZdQ45gw,9743
3
+ drift_engine/core.py,sha256=QyQnaNAbjou_EhIK_iwZ2gAEYFJXYZjYW9xrpwamXIY,6483
4
+ drift_engine/database.py,sha256=6pSgmSnDx42dcnzCU7PgE3Dea1YzLAqe05gOA9i6eKI,1813
5
+ drift_engine/explain.py,sha256=MwdlWHHMRC9jqZPsagxa4OXSpN_Ag2nZSRMgfgSsjRA,3011
6
+ drift_engine/models.py,sha256=A5oSeXiG4SY8j322FNGZPFe4IOfKniNcCozEltQubqM,1818
7
+ drift_engine/notifications.py,sha256=_DHdXKYYVsaSPTAKtpSmnrEQWGmvzmJycZ8afWdW5HU,4170
8
+ drift_engine/remediation.py,sha256=WQs4QRrvaQzTGRs0LJ2yxDRyILJPgJ69igcdC0yQIy0,14307
9
+ drift_engine/tf_parser.py,sha256=rNJh599REEmvM9eHHoQFJ4hqOZ4U0ZoQ4TKIkk6fdIU,2891
10
+ driftwatch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ driftwatch/cli.py,sha256=sCJCj5UTpezP2v4WZnIY-fGmdWo79dCd7nh2sH3HMrE,8110
12
+ driftwatch_cli-0.1.0.dist-info/licenses/LICENSE,sha256=ItNresBCeEWpUoZYaunXiqE6MQvpXlobydKTroNviLQ,1068
13
+ driftwatch_cli-0.1.0.dist-info/METADATA,sha256=3Xd0UQfnuNsSEmF_iacfFzFZNXe4a-D_pi0sLle9mfw,6107
14
+ driftwatch_cli-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
15
+ driftwatch_cli-0.1.0.dist-info/entry_points.txt,sha256=lr6se5fEsOxPcWRmBIapnQMptHzZEryk6VdCy_oAq-Q,50
16
+ driftwatch_cli-0.1.0.dist-info/top_level.txt,sha256=xp0kkk7SQJ2Q9fa3BR-MWAgp3kheLeb_xqE1INy6O10,24
17
+ driftwatch_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ driftwatch = driftwatch.cli:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nitin Gupta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ drift_engine
2
+ driftwatch