sarj-iac-lint
Custom Terraform / IaC lint rules — stdlib only, line/block based, pre-commit-friendly. Mined from recurring infra review comments across the org.
uv tool install sarj-iac-lint
Rules
| Code | Rule | What it flags |
|---|---|---|
| SARJ201 | require-deletion-protection |
A stateful resource (Cloud SQL, GKE, BigQuery, Spanner, AlloyDB, Bigtable, RDS, DynamoDB, ElastiCache, DocumentDB, Neptune, Azure databases, Cosmos DB, ...) without deletion_protection = true. |
| SARJ202 | no-comment-cruft |
Commented-out Terraform/HCL and section-banner / divider comments. |
| SARJ203 | require-prevent-destroy-on-irreplaceable |
An irreplaceable bucket, secret, or artifact registry without an effective provider-side deletion guard or lifecycle { prevent_destroy = true }. |
Terraform safety rules scan .tf files; comment hygiene also scans .hcl and .tfvars. .yaml/.yml
(Helm/k8s/Compose) are scanned by no-comment-cruft for banners only.
Pre-commit
- repo: https://github.com/sarj-ai/standards
rev: iac-v0.6.0
hooks:
- id: sarj-require-deletion-protection
- id: sarj-no-comment-cruft-iac
- id: sarj-require-prevent-destroy-on-irreplaceable
CLI
sarj-iac-lint check --rule require-deletion-protection iac/
sarj-iac-lint list-rules
Diagnostic format is path:line:col: CODE message — Ruff-compatible.
--exit-zero reports without failing (warn mode).
Adoption
All three rules are designed for hard (blocking) adoption; inspect existing findings before enabling them repository-wide.
Variable/expression-gated protection is not proof of protection:
deletion_protection must be a literal
true, or lifecycle { prevent_destroy = true } must be present. Protection
must sit on the resource itself: a flag nested in settings { ... } is the
API-side switch and does not stop terraform destroy.
Memorystore Redis is protected when deletion_protection is omitted; an
explicit false remains unsafe. Current Google resources covered by SARJ201
also accept their documented literal deletion_policy = "PREVENT" guard;
AlloyDB is deliberately excluded because its same-named policy means
DEFAULT/FORCE, not Terraform deletion prevention.
require-prevent-destroy-on-irreplaceable accepts the current Google provider's
literal deletion_policy = "PREVENT" for Cloud Storage buckets, Secret Manager
secrets, and Artifact Registry repositories. Secret Manager also accepts literal
deletion_protection = true. Other values and expressions are not proof of
protection; lifecycle { prevent_destroy = true } remains the portable guard.
The rule also exempts resources explicitly declared disposable with literal
force_destroy = true.
Suppression
Inline # sarj-noqa: SARJ201 — <reason> on the reported line. SARJ201 and
SARJ203 report the resource line.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sarj_iac_lint-0.6.1-py3-none-any.whl.
File metadata
- Download URL: sarj_iac_lint-0.6.1-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
497c50b73a0809ba4d749c842141367d3bd9482b01df05dbcc76c37baf07a752
|
|
| MD5 |
a0f73014a8d621006a4bd3790ef2bd0f
|
|
| BLAKE2b-256 |
22af7a2d1795dbf659a95b84456d01929ab52ae6fa93530f9240864ed9690ada
|
Provenance
The following attestation bundles were made for sarj_iac_lint-0.6.1-py3-none-any.whl:
Publisher:
release.yml on sarj-ai/standards
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sarj_iac_lint-0.6.1-py3-none-any.whl -
Subject digest:
497c50b73a0809ba4d749c842141367d3bd9482b01df05dbcc76c37baf07a752 - Sigstore transparency entry: 2361203175
- Sigstore integration time:
-
Permalink:
sarj-ai/standards@b9ae34abdee59c1d7408062880a614bcc1820d8e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sarj-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9ae34abdee59c1d7408062880a614bcc1820d8e -
Trigger Event:
push
-
Statement type: