cloud-drift-report 0.2.0__tar.gz
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.
- cloud_drift_report-0.2.0/LICENSE +202 -0
- cloud_drift_report-0.2.0/PKG-INFO +305 -0
- cloud_drift_report-0.2.0/README.md +285 -0
- cloud_drift_report-0.2.0/pyproject.toml +37 -0
- cloud_drift_report-0.2.0/setup.cfg +4 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/aws_inventory.py +1029 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/cloud_drift_report.egg-info/PKG-INFO +305 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/cloud_drift_report.egg-info/SOURCES.txt +13 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/cloud_drift_report.egg-info/dependency_links.txt +1 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/cloud_drift_report.egg-info/entry_points.txt +2 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/cloud_drift_report.egg-info/requires.txt +4 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/cloud_drift_report.egg-info/top_level.txt +2 -0
- cloud_drift_report-0.2.0/skills/cloud-drift-report/scripts/drift_report.py +816 -0
- cloud_drift_report-0.2.0/tests/test_aws_inventory.py +227 -0
- cloud_drift_report-0.2.0/tests/test_drift_report.py +329 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cloud-drift-report
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Read-only drift and not-in-IaC report for Terraform/OpenTofu (any cloud) and AWS CloudFormation
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://www.orchesterra.in/?utm_source=drift-skill&utm_medium=oss
|
|
7
|
+
Project-URL: Repository, https://github.com/orchesterra/cloud-drift-report
|
|
8
|
+
Project-URL: Issues, https://github.com/orchesterra/cloud-drift-report/issues
|
|
9
|
+
Keywords: aws,azure,gcp,oci,terraform,opentofu,cloudformation,drift,driftctl,unmanaged,clickops
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Topic :: System :: Systems Administration
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: boto3
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
Requires-Dist: pytest; extra == "test"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# cloud-drift-report
|
|
22
|
+
|
|
23
|
+
A read-only drift report for your cloud infrastructure. It finds resources that someone changed or deleted
|
|
24
|
+
outside your Terraform, OpenTofu or CloudFormation code, and resources that exist in your account but no state
|
|
25
|
+
file or stack knows about. It ranks them by severity and explains each one in plain English.
|
|
26
|
+
|
|
27
|
+
| | AWS | Azure, GCP, OCI |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| Terraform / OpenTofu drift | ✅ | ✅ (any provider `plan -refresh-only` can refresh) |
|
|
30
|
+
| CloudFormation drift | ✅ | — |
|
|
31
|
+
| Resources not in any IaC | ✅ | planned |
|
|
32
|
+
|
|
33
|
+
It ships three ways, from the same code:
|
|
34
|
+
|
|
35
|
+
- a **command-line tool** (`cloud-drift-report`)
|
|
36
|
+
- a **Claude skill** (Claude Code, Claude desktop and claude.ai)
|
|
37
|
+
- a **Cursor skill**, plus a Cursor rule for older versions
|
|
38
|
+
|
|
39
|
+
It never writes to AWS or to Terraform state, sends no telemetry and needs no account.
|
|
40
|
+
|
|
41
|
+
> **Built by [OrchesTerra](https://www.orchesterra.in/?utm_source=drift-skill&utm_medium=oss).** This free tool is a one-off check from your laptop or CI.
|
|
42
|
+
> OrchesTerra is the cloud platform that runs it continuously across all your AWS accounts and fixes what
|
|
43
|
+
> it finds, with approvals. [Try the live demo](https://app.orchesterra.in/auth/login?demo=1&utm_source=drift-skill&utm_medium=oss) (no sign-up) or [see what it does](#orchesterra-the-full-platform).
|
|
44
|
+
|
|
45
|
+
## What it checks
|
|
46
|
+
|
|
47
|
+
| Source | How |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Terraform / OpenTofu | Runs `plan -refresh-only -lock=false` into a temporary plan file and reads it with `show -json`, or reads a plan JSON you already have. |
|
|
50
|
+
| CloudFormation | Runs drift detection on the stacks you name (or every stack in a region), waits for it, then reads the resource drifts. |
|
|
51
|
+
| Not in IaC | Lists the account (about 170 resource types, mostly through the AWS Cloud Control API) and compares it with your Terraform state files and CloudFormation stacks. Anything neither lists is reported. |
|
|
52
|
+
|
|
53
|
+
For each drifted resource you get the address, type, action (changed or deleted outside IaC), each changed
|
|
54
|
+
attribute (before → after), a severity, and a short "what probably happened". For each resource not in IaC you
|
|
55
|
+
get its name, region, type, ID or ARN and a severity.
|
|
56
|
+
|
|
57
|
+
The not-in-IaC scan skips what AWS creates itself: default VPCs and their subnets, route tables and security
|
|
58
|
+
groups, service-linked roles, AWS-managed keys and policies, and resources another AWS service owns (an EKS
|
|
59
|
+
cluster security group, an RDS-managed secret, instances launched by an Auto Scaling group). They are counted
|
|
60
|
+
in the report's coverage line but not listed as findings. Types it could not list (access denied, or the type
|
|
61
|
+
needs a parent resource) are named in the JSON output, so you know what was not checked.
|
|
62
|
+
|
|
63
|
+
**Severity**
|
|
64
|
+
|
|
65
|
+
- **High**: security relevant. Security groups and rules, NACLs, IAM, bucket policies, public access,
|
|
66
|
+
ACLs, encryption, KMS, resource policies, passwords.
|
|
67
|
+
- **Medium**: any other change that alters behaviour, deleted resources, and most resources not in IaC.
|
|
68
|
+
- **Low**: tags only, and log groups an AWS service created for one of your resources.
|
|
69
|
+
|
|
70
|
+
Formats: Markdown (default), CSV, JSON and a self-contained HTML page (no external assets, light and dark mode,
|
|
71
|
+
severity filter).
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
You need Python 3.10+. The CloudFormation and not-in-IaC modes also need `boto3`; Terraform mode needs `tofu`
|
|
76
|
+
or `terraform` on PATH.
|
|
77
|
+
|
|
78
|
+
### Command-line tool
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install cloud-drift-report
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or the latest code from GitHub: `pip install git+https://github.com/orchesterra/cloud-drift-report`.
|
|
85
|
+
|
|
86
|
+
Or run the script directly with no install:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
python3 skills/cloud-drift-report/scripts/drift_report.py --help
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Claude skill
|
|
93
|
+
|
|
94
|
+
Copy the skill folder into your Claude skills directory:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
cp -r skills/cloud-drift-report ~/.claude/skills/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Then ask Claude: *"check drift in ./infra"*, *"make a drift report for my CloudFormation stacks in us-east-1"*,
|
|
101
|
+
*"what changed outside Terraform?"* or *"what in this account isn't in Terraform?"*
|
|
102
|
+
|
|
103
|
+
### Cursor skill
|
|
104
|
+
|
|
105
|
+
Cursor versions with Agent Skills read the same folder:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
mkdir -p ~/.cursor/skills && cp -r skills/cloud-drift-report ~/.cursor/skills/
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For older Cursor versions, copy the rule into your project instead:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
mkdir -p .cursor/rules && cp cursor/rules/cloud-drift-report.mdc .cursor/rules/
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Credentials
|
|
118
|
+
|
|
119
|
+
The tool never asks for, stores or sends credentials. It uses whatever is already set up on the machine,
|
|
120
|
+
through the standard AWS credential chain (the same one the AWS CLI uses):
|
|
121
|
+
|
|
122
|
+
| How you sign in | How to run it |
|
|
123
|
+
|---|---|
|
|
124
|
+
| SSO (IAM Identity Center), recommended | `aws sso login --profile prod`, then `--profile prod` |
|
|
125
|
+
| Assume-role profile (`role_arn` + `source_profile` in `~/.aws/config`) | `--profile <name>` |
|
|
126
|
+
| Access keys in `~/.aws/credentials` | `--profile <name>`, or nothing for `default` |
|
|
127
|
+
| Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_PROFILE`, ...) | no flag needed |
|
|
128
|
+
| CI with OIDC (GitHub Actions, GitLab), or an EC2/ECS/Lambda role | no flag needed |
|
|
129
|
+
|
|
130
|
+
Terraform/OpenTofu mode runs `tofu` or `terraform`, so the provider reads its own credentials: `--profile`
|
|
131
|
+
there sets `AWS_PROFILE` for the AWS provider; Azure, GCP and OCI providers use their usual environment
|
|
132
|
+
variables or CLI login (`az login`, `gcloud auth application-default login`, `~/.oci/config`).
|
|
133
|
+
|
|
134
|
+
Prefer SSO or a role over long-lived access keys. The AWS managed `ReadOnlyAccess` policy covers everything
|
|
135
|
+
the tool reads; see [Safety](#safety) for the exact calls.
|
|
136
|
+
|
|
137
|
+
### In GitHub Actions
|
|
138
|
+
|
|
139
|
+
Run it on a schedule with a read-only role (no stored keys, using GitHub's OIDC). The job fails when something
|
|
140
|
+
drifted or is not in IaC, and the HTML report is kept as an artifact:
|
|
141
|
+
|
|
142
|
+
```yaml
|
|
143
|
+
name: drift-report
|
|
144
|
+
on:
|
|
145
|
+
schedule: [{ cron: "0 6 * * 1-5" }] # weekdays 06:00 UTC
|
|
146
|
+
workflow_dispatch:
|
|
147
|
+
permissions:
|
|
148
|
+
id-token: write # for OIDC
|
|
149
|
+
contents: read
|
|
150
|
+
jobs:
|
|
151
|
+
drift:
|
|
152
|
+
runs-on: ubuntu-latest
|
|
153
|
+
steps:
|
|
154
|
+
- uses: actions/checkout@v4
|
|
155
|
+
- uses: aws-actions/configure-aws-credentials@v4
|
|
156
|
+
with:
|
|
157
|
+
role-to-assume: arn:aws:iam::123456789012:role/drift-report-readonly
|
|
158
|
+
aws-region: us-east-1
|
|
159
|
+
- uses: actions/setup-python@v5
|
|
160
|
+
with: { python-version: "3.12" }
|
|
161
|
+
- run: pip install cloud-drift-report
|
|
162
|
+
- run: >
|
|
163
|
+
cloud-drift-report unmanaged --state s3://acme-tf-state/prod/
|
|
164
|
+
--format html -o not-in-iac.html --fail-on-drift
|
|
165
|
+
- if: always()
|
|
166
|
+
uses: actions/upload-artifact@v4
|
|
167
|
+
with: { name: drift-report, path: not-in-iac.html }
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
For Terraform drift in CI, add `hashicorp/setup-terraform` or `opentofu/setup-opentofu`, run `init` in your
|
|
171
|
+
directory, then `cloud-drift-report terraform --dir ./infra --fail-on-drift`.
|
|
172
|
+
|
|
173
|
+
## Examples
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Terraform/OpenTofu directory (must already be initialised), Markdown to the terminal
|
|
177
|
+
AWS_PROFILE=prod cloud-drift-report terraform --dir ./infra
|
|
178
|
+
|
|
179
|
+
# An existing plan file
|
|
180
|
+
tofu plan -refresh-only -out=plan.out && tofu show -json plan.out > plan.json
|
|
181
|
+
cloud-drift-report terraform --plan-json plan.json --format html -o drift.html
|
|
182
|
+
|
|
183
|
+
# CloudFormation: two stacks, or every stack in a region
|
|
184
|
+
cloud-drift-report cloudformation --profile prod --region us-east-1 --stack payments-api --stack network
|
|
185
|
+
cloud-drift-report cloudformation --profile prod --region us-east-1 --format csv -o drift.csv
|
|
186
|
+
|
|
187
|
+
# Not in IaC: compare us-east-1 with every state file under an S3 prefix and all CloudFormation stacks
|
|
188
|
+
cloud-drift-report unmanaged --profile prod --region us-east-1 --state s3://acme-tf-state/prod/
|
|
189
|
+
|
|
190
|
+
# Not in IaC across every enabled region, several state sources, HTML report
|
|
191
|
+
cloud-drift-report unmanaged --profile prod --all-regions \
|
|
192
|
+
--state s3://acme-tf-state/ --state ./legacy/terraform.tfstate --format html -o not-in-iac.html
|
|
193
|
+
|
|
194
|
+
# CI: exit code 2 when drift (or a resource not in IaC) is found
|
|
195
|
+
cloud-drift-report terraform --dir ./infra --fail-on-drift
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Exit codes: `0` ok, `1` error, `2` drift or a resource not in IaC found with `--fail-on-drift`.
|
|
199
|
+
|
|
200
|
+
`--state` takes a local `.tfstate` file, `s3://bucket/key.tfstate`, `s3://bucket/prefix/` (every `.tfstate`
|
|
201
|
+
under it) or an initialised Terraform directory (read with `state pull`). It may repeat. Without `--state`,
|
|
202
|
+
only CloudFormation stacks count as IaC.
|
|
203
|
+
|
|
204
|
+
## Sample output
|
|
205
|
+
|
|
206
|
+
```text
|
|
207
|
+
# Drift report: ./infra/prod
|
|
208
|
+
|
|
209
|
+
**6 drifted resources** · high: 3 · medium: 2 · low: 1
|
|
210
|
+
|
|
211
|
+
| Severity | Resource | Action | Changes (before → after) | What probably happened |
|
|
212
|
+
|----------|----------------------------|---------------------|------------------------------------------------------------|------------------------|
|
|
213
|
+
| HIGH | aws_security_group.web | changed outside IaC | ingress[1]: (none) → {"cidr_blocks": ["0.0.0.0/0"], ... 22} | Security group rule edited outside IaC and now open to the internet. |
|
|
214
|
+
| HIGH | aws_iam_role_policy.app | changed outside IaC | policy: s3:GetObject → s3:* | Policy or permissions edited outside IaC; review who gained or lost access. |
|
|
215
|
+
| MEDIUM | aws_instance.worker | changed outside IaC | instance_type: t3.small → t3.large | Edited outside IaC, likely a console or CLI change to instance_type. |
|
|
216
|
+
| MEDIUM | aws_sqs_queue.jobs | deleted outside IaC | resource no longer exists | Deleted outside IaC; the code still expects it. |
|
|
217
|
+
| LOW | aws_s3_bucket.logs | changed outside IaC | tags.CostCenter: (none) → 1234 | Tag added outside IaC. |
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Full samples in every format are in [`examples/`](https://github.com/orchesterra/cloud-drift-report/tree/main/examples): Terraform
|
|
221
|
+
([md](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/terraform-drift.md), [csv](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/terraform-drift.csv), [json](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/terraform-drift.json),
|
|
222
|
+
[html](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/terraform-drift.html)) and CloudFormation
|
|
223
|
+
([md](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/cloudformation-drift.md), [csv](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/cloudformation-drift.csv),
|
|
224
|
+
[json](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/cloudformation-drift.json), [html](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/cloudformation-drift.html)) and not in IaC
|
|
225
|
+
([md](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/not-in-iac.md), [csv](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/not-in-iac.csv), [json](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/not-in-iac.json),
|
|
226
|
+
[html](https://github.com/orchesterra/cloud-drift-report/blob/main/examples/not-in-iac.html)).
|
|
227
|
+
Regenerate them with `python3 examples/generate.py`.
|
|
228
|
+
|
|
229
|
+
## Safety
|
|
230
|
+
|
|
231
|
+
- Terraform: only `plan -refresh-only -lock=false` and `show -json`. No `apply`, `import`, `state` or
|
|
232
|
+
`refresh`. The plan file goes to a temporary folder and is deleted. Sensitive values are masked.
|
|
233
|
+
- CloudFormation: `DetectStackDrift`, `DescribeStackDriftDetectionStatus`, `DescribeStackResourceDrifts`
|
|
234
|
+
and `ListStacks`. Drift detection records a check on the stack; nothing else changes.
|
|
235
|
+
- Not in IaC: only List, Describe and Get calls (Cloud Control `ListResources`, plus a few service list calls
|
|
236
|
+
such as `ec2:DescribeVpcs` and `iam:ListRoles`), `cloudformation:ListStackResources`, and reads of the state
|
|
237
|
+
files you name. State files are read in memory and never printed or saved.
|
|
238
|
+
- Uses your own credentials (see [Credentials](#credentials)). The AWS managed `ReadOnlyAccess` policy is enough, plus
|
|
239
|
+
`cloudformation:DetectStackDrift` for CloudFormation drift and whatever read permissions your Terraform
|
|
240
|
+
provider needs to refresh.
|
|
241
|
+
|
|
242
|
+
## Coming soon: `--share`
|
|
243
|
+
|
|
244
|
+
`--share` will upload the HTML report to OrchesTerra as a private page your teammates can open. It is not
|
|
245
|
+
live yet: the flag currently prints a note and uploads nothing. It will always be opt-in.
|
|
246
|
+
|
|
247
|
+
## Why we built it
|
|
248
|
+
|
|
249
|
+
[driftctl](https://github.com/snyk/driftctl) used to be the go-to free drift checker, but it is no longer
|
|
250
|
+
actively maintained. Terraform and OpenTofu can now detect drift themselves with `plan -refresh-only`, and
|
|
251
|
+
CloudFormation has drift detection built in, but both print raw output that is hard to triage, and neither
|
|
252
|
+
tells you about resources your code never knew about. This tool turns the first into a short, ranked report,
|
|
253
|
+
finds the second by listing the account, and lets Claude or Cursor explain both.
|
|
254
|
+
|
|
255
|
+
The account listing and the rules for what AWS owns come from
|
|
256
|
+
[OrchesTerra](https://www.orchesterra.in/?utm_source=drift-skill&utm_medium=oss)'s own drift scanner, simplified
|
|
257
|
+
to run as a single command.
|
|
258
|
+
|
|
259
|
+
## OrchesTerra: the full platform
|
|
260
|
+
|
|
261
|
+
This tool tells you what has drifted and what is not in code, once. [OrchesTerra](https://www.orchesterra.in/?utm_source=drift-skill&utm_medium=oss) is a hosted
|
|
262
|
+
platform for AWS that keeps doing it, fixes what it finds, and runs the rest of your infrastructure workflow
|
|
263
|
+
in one place.
|
|
264
|
+
|
|
265
|
+
| | cloud-drift-report (free) | OrchesTerra (paid, cloud) |
|
|
266
|
+
|---|---|---|
|
|
267
|
+
| Drift in Terraform/OpenTofu and CloudFormation | ✅ one run | ✅ scheduled scans, history and trends |
|
|
268
|
+
| Resources not in any IaC | ✅ one run | ✅ continuous, every AWS service |
|
|
269
|
+
| Accounts and regions | one per run | many accounts and regions in one view |
|
|
270
|
+
| Alerts | — | Slack and email |
|
|
271
|
+
| Fix drift | — | restore to code, or accept the change into code |
|
|
272
|
+
| Bring unmanaged resources into code | — | adopt into Terraform or a CloudFormation stack, with the import done for you |
|
|
273
|
+
| Approvals and safety | — | approvals for risky changes, critical resources protected |
|
|
274
|
+
| Team access | — | workspaces, roles and an audit log |
|
|
275
|
+
|
|
276
|
+
**What else OrchesTerra does**
|
|
277
|
+
|
|
278
|
+
- **Drift and adoption**: scans Terraform and CloudFormation on a schedule, and restores, accepts or adopts each finding with one click and an approval step.
|
|
279
|
+
- **Provisioning**: AWS service forms and a visual designer that produce reviewed Terraform, with plan
|
|
280
|
+
previews, cost estimates and quota checks before anything is applied.
|
|
281
|
+
- **Pull request checks**: the plan and its cost impact posted on GitHub, GitLab and Bitbucket pull requests.
|
|
282
|
+
- **Policy and compliance**: a policy catalog with guardrails mapped to common frameworks, custom rules,
|
|
283
|
+
exceptions, and checks on existing infrastructure.
|
|
284
|
+
- **Cost control**: budgets with alerts, cost estimates on every change, and auto-destroy for temporary
|
|
285
|
+
environments.
|
|
286
|
+
- **Disaster recovery**: a readiness score per application and scheduled DR drills.
|
|
287
|
+
- **Platform tools**: a private Terraform module registry, shared variable sets, scheduled runs, and an MCP
|
|
288
|
+
server so Claude and other AI tools can read your estate.
|
|
289
|
+
|
|
290
|
+
Start with a 14-day free trial; paid plans start at $99 a month. See [pricing](https://www.orchesterra.in/pricing?utm_source=drift-skill&utm_medium=oss), or
|
|
291
|
+
[open the live demo](https://app.orchesterra.in/auth/login?demo=1&utm_source=drift-skill&utm_medium=oss) to look around a sample workspace without signing up.
|
|
292
|
+
|
|
293
|
+
## Development
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
pip install -e '.[test]'
|
|
297
|
+
pytest
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The tests use a fake refresh-only plan, a fake CloudFormation client and a fake AWS session, so they need no
|
|
301
|
+
AWS access.
|
|
302
|
+
|
|
303
|
+
## Licence
|
|
304
|
+
|
|
305
|
+
Apache-2.0. See [LICENSE](https://github.com/orchesterra/cloud-drift-report/blob/main/LICENSE).
|