@intentius/chant-lexicon-terraform 0.101.0 → 0.104.0

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.
Files changed (374) hide show
  1. package/dist/__fixtures__/terragrunt/affected-cases.d.ts +23 -0
  2. package/dist/__fixtures__/terragrunt/affected-cases.d.ts.map +1 -0
  3. package/dist/__fixtures__/terragrunt/record.d.ts +17 -0
  4. package/dist/__fixtures__/terragrunt/record.d.ts.map +1 -0
  5. package/dist/change-set.d.ts +67 -0
  6. package/dist/change-set.d.ts.map +1 -0
  7. package/dist/changed-roots.d.ts +30 -0
  8. package/dist/changed-roots.d.ts.map +1 -0
  9. package/dist/codegen/package.d.ts +1 -1
  10. package/dist/commands.d.ts +26 -0
  11. package/dist/commands.d.ts.map +1 -0
  12. package/dist/components/capability-plugin.d.ts +54 -0
  13. package/dist/components/capability-plugin.d.ts.map +1 -0
  14. package/dist/composites/terraform-pin-rollout-op.d.ts +44 -0
  15. package/dist/composites/terraform-pin-rollout-op.d.ts.map +1 -0
  16. package/dist/config.d.ts +3 -3
  17. package/dist/hcl/descend.d.ts +1 -1
  18. package/dist/hcl/descend.d.ts.map +1 -1
  19. package/dist/hcl/edges.d.ts +2 -2
  20. package/dist/hcl/edges.d.ts.map +1 -1
  21. package/dist/hcl/jsonencode.d.ts +106 -0
  22. package/dist/hcl/jsonencode.d.ts.map +1 -0
  23. package/dist/hcl/marker.d.ts.map +1 -1
  24. package/dist/hcl/parse.d.ts +29 -1
  25. package/dist/hcl/parse.d.ts.map +1 -1
  26. package/dist/hcl/roots.d.ts +1 -1
  27. package/dist/hcl/roots.d.ts.map +1 -1
  28. package/dist/hcl/suppressions.d.ts.map +1 -1
  29. package/dist/index.d.ts +4 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/integrity.json +22 -4
  32. package/dist/lint/audit-catalog.d.ts.map +1 -1
  33. package/dist/lint/audit-lineage.d.ts +1 -1
  34. package/dist/lint/audit-lineage.d.ts.map +1 -1
  35. package/dist/lint/post-synth/flat-attributes.d.ts +69 -0
  36. package/dist/lint/post-synth/flat-attributes.d.ts.map +1 -0
  37. package/dist/lint/post-synth/index.d.ts.map +1 -1
  38. package/dist/lint/post-synth/module-source.d.ts +27 -1
  39. package/dist/lint/post-synth/module-source.d.ts.map +1 -1
  40. package/dist/lint/post-synth/terragrunt.d.ts +37 -0
  41. package/dist/lint/post-synth/terragrunt.d.ts.map +1 -0
  42. package/dist/lint/post-synth/tf002.d.ts +3 -1
  43. package/dist/lint/post-synth/tf002.d.ts.map +1 -1
  44. package/dist/lint/post-synth/tf030.d.ts +51 -0
  45. package/dist/lint/post-synth/tf030.d.ts.map +1 -0
  46. package/dist/lint/post-synth/tf031.d.ts +55 -0
  47. package/dist/lint/post-synth/tf031.d.ts.map +1 -0
  48. package/dist/lint/post-synth/tf032.d.ts +71 -0
  49. package/dist/lint/post-synth/tf032.d.ts.map +1 -0
  50. package/dist/lint/post-synth/tf033.d.ts +50 -0
  51. package/dist/lint/post-synth/tf033.d.ts.map +1 -0
  52. package/dist/lint/post-synth/tf034.d.ts +25 -0
  53. package/dist/lint/post-synth/tf034.d.ts.map +1 -0
  54. package/dist/lint/post-synth/tf035.d.ts +33 -0
  55. package/dist/lint/post-synth/tf035.d.ts.map +1 -0
  56. package/dist/lint/post-synth/tf036.d.ts +33 -0
  57. package/dist/lint/post-synth/tf036.d.ts.map +1 -0
  58. package/dist/lint/post-synth/tf037.d.ts +31 -0
  59. package/dist/lint/post-synth/tf037.d.ts.map +1 -0
  60. package/dist/lint/post-synth/tf038.d.ts +22 -0
  61. package/dist/lint/post-synth/tf038.d.ts.map +1 -0
  62. package/dist/lint/post-synth/tf039.d.ts +23 -0
  63. package/dist/lint/post-synth/tf039.d.ts.map +1 -0
  64. package/dist/lint/post-synth/tf040.d.ts +30 -0
  65. package/dist/lint/post-synth/tf040.d.ts.map +1 -0
  66. package/dist/lint/post-synth/tf041.d.ts +20 -0
  67. package/dist/lint/post-synth/tf041.d.ts.map +1 -0
  68. package/dist/lint/post-synth/tf042.d.ts +18 -0
  69. package/dist/lint/post-synth/tf042.d.ts.map +1 -0
  70. package/dist/lint/post-synth/tf043.d.ts +17 -0
  71. package/dist/lint/post-synth/tf043.d.ts.map +1 -0
  72. package/dist/lint/post-synth/tf044.d.ts +17 -0
  73. package/dist/lint/post-synth/tf044.d.ts.map +1 -0
  74. package/dist/lint/post-synth/tf045.d.ts +22 -0
  75. package/dist/lint/post-synth/tf045.d.ts.map +1 -0
  76. package/dist/manifest.json +1 -1
  77. package/dist/okf/index.md +16 -0
  78. package/dist/okf/rules/TF030.md +11 -0
  79. package/dist/okf/rules/TF031.md +11 -0
  80. package/dist/okf/rules/TF032.md +11 -0
  81. package/dist/okf/rules/TF033.md +11 -0
  82. package/dist/okf/rules/TF034.md +11 -0
  83. package/dist/okf/rules/TF035.md +11 -0
  84. package/dist/okf/rules/TF036.md +11 -0
  85. package/dist/okf/rules/TF037.md +11 -0
  86. package/dist/okf/rules/TF038.md +11 -0
  87. package/dist/okf/rules/TF039.md +11 -0
  88. package/dist/okf/rules/TF040.md +11 -0
  89. package/dist/okf/rules/TF041.md +11 -0
  90. package/dist/okf/rules/TF042.md +11 -0
  91. package/dist/okf/rules/TF043.md +11 -0
  92. package/dist/okf/rules/TF044.md +11 -0
  93. package/dist/okf/rules/TF045.md +11 -0
  94. package/dist/op/activities/index.d.ts +4 -0
  95. package/dist/op/activities/index.d.ts.map +1 -1
  96. package/dist/op/activities/pin-rollout.d.ts +46 -0
  97. package/dist/op/activities/pin-rollout.d.ts.map +1 -0
  98. package/dist/op/activities/terraform.d.ts +24 -50
  99. package/dist/op/activities/terraform.d.ts.map +1 -1
  100. package/dist/op/activity-contracts.d.ts +66 -18
  101. package/dist/op/activity-contracts.d.ts.map +1 -1
  102. package/dist/op/builders.d.ts +9 -0
  103. package/dist/op/builders.d.ts.map +1 -1
  104. package/dist/pin/edit-ts.d.ts +21 -0
  105. package/dist/pin/edit-ts.d.ts.map +1 -0
  106. package/dist/pin/edit.d.ts +52 -0
  107. package/dist/pin/edit.d.ts.map +1 -0
  108. package/dist/pin/forge.d.ts +39 -0
  109. package/dist/pin/forge.d.ts.map +1 -0
  110. package/dist/pin/index.d.ts +22 -0
  111. package/dist/pin/index.d.ts.map +1 -0
  112. package/dist/pin/rollout.d.ts +116 -0
  113. package/dist/pin/rollout.d.ts.map +1 -0
  114. package/dist/pin/scan.d.ts +54 -0
  115. package/dist/pin/scan.d.ts.map +1 -0
  116. package/dist/pin/source.d.ts +93 -0
  117. package/dist/pin/source.d.ts.map +1 -0
  118. package/dist/pin/waves.d.ts +66 -0
  119. package/dist/pin/waves.d.ts.map +1 -0
  120. package/dist/plan-digest.d.ts +59 -0
  121. package/dist/plan-digest.d.ts.map +1 -0
  122. package/dist/plugin.d.ts.map +1 -1
  123. package/dist/rules/flat-attributes.ts +146 -0
  124. package/dist/rules/module-source.ts +56 -1
  125. package/dist/rules/terragrunt.ts +76 -0
  126. package/dist/rules/tf002.ts +1 -1
  127. package/dist/rules/tf030.ts +290 -0
  128. package/dist/rules/tf031.ts +370 -0
  129. package/dist/rules/tf032.ts +226 -0
  130. package/dist/rules/tf033.ts +160 -0
  131. package/dist/rules/tf034.ts +63 -0
  132. package/dist/rules/tf035.ts +74 -0
  133. package/dist/rules/tf036.ts +119 -0
  134. package/dist/rules/tf037.ts +101 -0
  135. package/dist/rules/tf038.ts +71 -0
  136. package/dist/rules/tf039.ts +64 -0
  137. package/dist/rules/tf040.ts +76 -0
  138. package/dist/rules/tf041.ts +56 -0
  139. package/dist/rules/tf042.ts +42 -0
  140. package/dist/rules/tf043.ts +49 -0
  141. package/dist/rules/tf044.ts +51 -0
  142. package/dist/rules/tf045.ts +47 -0
  143. package/dist/terragrunt/affected.d.ts +119 -0
  144. package/dist/terragrunt/affected.d.ts.map +1 -0
  145. package/dist/terragrunt/index.d.ts +11 -0
  146. package/dist/terragrunt/index.d.ts.map +1 -0
  147. package/dist/terragrunt/mocks.d.ts +147 -0
  148. package/dist/terragrunt/mocks.d.ts.map +1 -0
  149. package/dist/terragrunt/run.d.ts +130 -0
  150. package/dist/terragrunt/run.d.ts.map +1 -0
  151. package/dist/terragrunt/units.d.ts +103 -0
  152. package/dist/terragrunt/units.d.ts.map +1 -0
  153. package/dist/terragrunt/wave.d.ts +89 -0
  154. package/dist/terragrunt/wave.d.ts.map +1 -0
  155. package/package.json +13 -3
  156. package/src/__fixtures__/change-set/choudoufu-set-plan.change-set.golden.json +95 -0
  157. package/src/__fixtures__/change-set/choudoufu-set-plan.json +76 -0
  158. package/src/__fixtures__/change-set/choudoufu.part.golden.json +173 -0
  159. package/src/__fixtures__/change-set/choudoufu.plan.json +610 -0
  160. package/src/__fixtures__/change-set/terraform.import-forget.plan.json +81 -0
  161. package/src/__fixtures__/change-set/terraform.part.golden.json +173 -0
  162. package/src/__fixtures__/change-set/terraform.plan.json +589 -0
  163. package/src/__fixtures__/change-set/tofu.part.golden.json +173 -0
  164. package/src/__fixtures__/change-set/tofu.plan.json +588 -0
  165. package/src/__fixtures__/change-set/v1.tf.txt +21 -0
  166. package/src/__fixtures__/change-set/v2-module-app.tf.txt +4 -0
  167. package/src/__fixtures__/change-set/v2.tf.txt +21 -0
  168. package/src/__fixtures__/pin/choudoufu-live-waves-n5.json +83 -0
  169. package/src/__fixtures__/pin/largeset-oci-n5/apply-order.txt +5 -0
  170. package/src/__fixtures__/pin/largeset-oci-n5/estates/e01/estate.chdf.hcl +6 -0
  171. package/src/__fixtures__/pin/largeset-oci-n5/estates/e01/main.tf +33 -0
  172. package/src/__fixtures__/pin/largeset-oci-n5/estates/e02/estate.chdf.hcl +6 -0
  173. package/src/__fixtures__/pin/largeset-oci-n5/estates/e02/main.tf +45 -0
  174. package/src/__fixtures__/pin/largeset-oci-n5/estates/e03/estate.chdf.hcl +6 -0
  175. package/src/__fixtures__/pin/largeset-oci-n5/estates/e03/main.tf +47 -0
  176. package/src/__fixtures__/pin/largeset-oci-n5/estates/e04/estate.chdf.hcl +6 -0
  177. package/src/__fixtures__/pin/largeset-oci-n5/estates/e04/main.tf +31 -0
  178. package/src/__fixtures__/pin/largeset-oci-n5/estates/e05/estate.chdf.hcl +6 -0
  179. package/src/__fixtures__/pin/largeset-oci-n5/estates/e05/main.tf +27 -0
  180. package/src/__fixtures__/pin/largeset-oci-n5/fixture.json +77 -0
  181. package/src/__fixtures__/plan-summary/largeset-n5-bump.json +2071 -0
  182. package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.json +95 -0
  183. package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.md +22 -0
  184. package/src/__fixtures__/plan-summary/largeset-n5.summary.golden.txt +12 -0
  185. package/src/__fixtures__/terragrunt/affected/catalog/units/web/terragrunt.hcl +3 -0
  186. package/src/__fixtures__/terragrunt/affected/gitignore +3 -0
  187. package/src/__fixtures__/terragrunt/affected/live/dev/app/terragrunt.hcl +3 -0
  188. package/src/__fixtures__/terragrunt/affected/live/dev/vpc/terragrunt.hcl +3 -0
  189. package/src/__fixtures__/terragrunt/affected/live/prod/app/terragrunt.hcl +3 -0
  190. package/src/__fixtures__/terragrunt/affected/live/stg/terragrunt.stack.hcl +5 -0
  191. package/src/__fixtures__/terragrunt/affected/modules/app/main.tf +6 -0
  192. package/src/__fixtures__/terragrunt/affected/modules/app/policy.json +1 -0
  193. package/src/__fixtures__/terragrunt/affected/modules/net/main.tf +2 -0
  194. package/src/__fixtures__/terragrunt/affected/modules/thing/main.tf +3 -0
  195. package/src/__fixtures__/terragrunt/affected/root.hcl +5 -0
  196. package/src/__fixtures__/terragrunt/affected-cases.ts +126 -0
  197. package/src/__fixtures__/terragrunt/five-units/catalog/units/thing/terragrunt.hcl +3 -0
  198. package/src/__fixtures__/terragrunt/five-units/live/dev/app/terragrunt.hcl +13 -0
  199. package/src/__fixtures__/terragrunt/five-units/live/dev/db/terragrunt.hcl +8 -0
  200. package/src/__fixtures__/terragrunt/five-units/live/dev/vpc/terragrunt.hcl +3 -0
  201. package/src/__fixtures__/terragrunt/five-units/live/prod/app/terragrunt.hcl +8 -0
  202. package/src/__fixtures__/terragrunt/five-units/live/prod/vpc/terragrunt.hcl +3 -0
  203. package/src/__fixtures__/terragrunt/five-units/modules/thing/main.tf +7 -0
  204. package/src/__fixtures__/terragrunt/five-units/root.hcl +5 -0
  205. package/src/__fixtures__/terragrunt/record.ts +56 -0
  206. package/src/__fixtures__/terragrunt/recorded/affected-find.json +50 -0
  207. package/src/__fixtures__/terragrunt/recorded/failed-plan-report.json +36 -0
  208. package/src/__fixtures__/terragrunt/recorded/find.json +67 -0
  209. package/src/__fixtures__/terragrunt/recorded/version.txt +1 -0
  210. package/src/__fixtures__/terragrunt/recorded/wave-1/apply-report.json +22 -0
  211. package/src/__fixtures__/terragrunt/recorded/wave-1/json/live/dev/vpc/tfplan.json +1 -0
  212. package/src/__fixtures__/terragrunt/recorded/wave-1/json/live/prod/vpc/tfplan.json +1 -0
  213. package/src/__fixtures__/terragrunt/recorded/wave-1/plan-report.json +22 -0
  214. package/src/__fixtures__/terragrunt/recorded/wave-2/json/live/dev/db/tfplan.json +1 -0
  215. package/src/__fixtures__/terragrunt/recorded/wave-2/json/live/prod/app/tfplan.json +1 -0
  216. package/src/__fixtures__/terragrunt/recorded/wave-2/plan-report.json +22 -0
  217. package/src/change-set-combined-run.test.ts +156 -0
  218. package/src/change-set.test.ts +151 -0
  219. package/src/change-set.ts +273 -0
  220. package/src/changed-roots.test.ts +58 -0
  221. package/src/changed-roots.ts +102 -0
  222. package/src/commands.ts +112 -0
  223. package/src/components/capability-plugin.test.ts +91 -0
  224. package/src/components/capability-plugin.ts +131 -0
  225. package/src/components/pr-loop.tofu.test.ts +244 -0
  226. package/src/composites/terraform-pin-rollout-op.test.ts +69 -0
  227. package/src/composites/terraform-pin-rollout-op.ts +60 -0
  228. package/src/hcl/descend.ts +1 -1
  229. package/src/hcl/edges.ts +2 -2
  230. package/src/hcl/jsonencode.test.ts +226 -0
  231. package/src/hcl/jsonencode.ts +454 -0
  232. package/src/hcl/parse.test.ts +25 -0
  233. package/src/hcl/parse.ts +91 -6
  234. package/src/hcl/roots.ts +1 -1
  235. package/src/hcl/suppressions.ts +8 -2
  236. package/src/index.ts +18 -0
  237. package/src/lint/audit-catalog.ts +230 -0
  238. package/src/lint/audit-lineage.ts +155 -1
  239. package/src/lint/audit.test.ts +3 -1
  240. package/src/lint/post-synth/estate-2284.test.ts +68 -0
  241. package/src/lint/post-synth/fixtures/TF030/negative-rules.tf +45 -0
  242. package/src/lint/post-synth/fixtures/TF030/negative.tf +55 -0
  243. package/src/lint/post-synth/fixtures/TF030/not-determined-port.tf +28 -0
  244. package/src/lint/post-synth/fixtures/TF030/not-determined-standalone.tf +32 -0
  245. package/src/lint/post-synth/fixtures/TF030/not-determined-vpc-rule.tf +21 -0
  246. package/src/lint/post-synth/fixtures/TF030/not-determined.tf +39 -0
  247. package/src/lint/post-synth/fixtures/TF030/positive-ipv6.tf +44 -0
  248. package/src/lint/post-synth/fixtures/TF030/positive-mixed.tf +36 -0
  249. package/src/lint/post-synth/fixtures/TF030/positive-standalone.tf +25 -0
  250. package/src/lint/post-synth/fixtures/TF030/positive.tf +43 -0
  251. package/src/lint/post-synth/fixtures/TF031/negative.tf +89 -0
  252. package/src/lint/post-synth/fixtures/TF031/not-determined.tf +139 -0
  253. package/src/lint/post-synth/fixtures/TF031/positive-data-source.tf +57 -0
  254. package/src/lint/post-synth/fixtures/TF031/positive-heredoc.tf +149 -0
  255. package/src/lint/post-synth/fixtures/TF031/positive-jsonencode.tf +115 -0
  256. package/src/lint/post-synth/fixtures/TF032/negative-heredoc.tf +20 -0
  257. package/src/lint/post-synth/fixtures/TF032/negative-references.tf +214 -0
  258. package/src/lint/post-synth/fixtures/TF032/negative.tf +99 -0
  259. package/src/lint/post-synth/fixtures/TF032/positive-heredoc.tf +22 -0
  260. package/src/lint/post-synth/fixtures/TF032/positive-sidecar.tf +197 -0
  261. package/src/lint/post-synth/fixtures/TF032/positive.tf +54 -0
  262. package/src/lint/post-synth/fixtures/TF033/negative.tf +39 -0
  263. package/src/lint/post-synth/fixtures/TF033/not-determined-aurora.tf +25 -0
  264. package/src/lint/post-synth/fixtures/TF033/positive-absent.tf +93 -0
  265. package/src/lint/post-synth/fixtures/TF033/positive.tf +50 -0
  266. package/src/lint/post-synth/fixtures/TF034/negative.tf +24 -0
  267. package/src/lint/post-synth/fixtures/TF034/positive-absent.tf +36 -0
  268. package/src/lint/post-synth/fixtures/TF034/positive.tf +14 -0
  269. package/src/lint/post-synth/fixtures/TF035/negative-absent.tf +43 -0
  270. package/src/lint/post-synth/fixtures/TF035/negative.tf +54 -0
  271. package/src/lint/post-synth/fixtures/TF035/positive.tf +37 -0
  272. package/src/lint/post-synth/fixtures/TF036/negative.tf +61 -0
  273. package/src/lint/post-synth/fixtures/TF036/not-determined.tf +28 -0
  274. package/src/lint/post-synth/fixtures/TF036/positive.tf +38 -0
  275. package/src/lint/post-synth/fixtures/TF037/negative-exclusion.tf +63 -0
  276. package/src/lint/post-synth/fixtures/TF037/negative.tf +27 -0
  277. package/src/lint/post-synth/fixtures/TF037/not-determined.tf +27 -0
  278. package/src/lint/post-synth/fixtures/TF037/positive-absent.tf +15 -0
  279. package/src/lint/post-synth/fixtures/TF037/positive.tf +26 -0
  280. package/src/lint/post-synth/fixtures/TF038/positive.tf +3 -0
  281. package/src/lint/post-synth/fixtures/TF039/positive.tf +4 -0
  282. package/src/lint/post-synth/fixtures/TF041/negative/terragrunt.hcl +12 -0
  283. package/src/lint/post-synth/fixtures/TF041/positive/terragrunt.hcl +7 -0
  284. package/src/lint/post-synth/fixtures/TF041/positive-apply/terragrunt.hcl +8 -0
  285. package/src/lint/post-synth/fixtures/TF042/negative/terragrunt.hcl +13 -0
  286. package/src/lint/post-synth/fixtures/TF042/positive/terragrunt.hcl +9 -0
  287. package/src/lint/post-synth/fixtures/TF043/negative/terragrunt.hcl +3 -0
  288. package/src/lint/post-synth/fixtures/TF043/negative-other/terragrunt.hcl +3 -0
  289. package/src/lint/post-synth/fixtures/TF043/positive-git/terragrunt.hcl +3 -0
  290. package/src/lint/post-synth/fixtures/TF043/positive-oci/terragrunt.hcl +3 -0
  291. package/src/lint/post-synth/fixtures/TF043/positive-tfr/terragrunt.hcl +3 -0
  292. package/src/lint/post-synth/fixtures/TF044/negative/terragrunt.hcl +9 -0
  293. package/src/lint/post-synth/fixtures/TF044/positive/terragrunt.hcl +7 -0
  294. package/src/lint/post-synth/fixtures/TF044/positive-generate/terragrunt.hcl +9 -0
  295. package/src/lint/post-synth/fixtures/TF045/negative/root.hcl +1 -0
  296. package/src/lint/post-synth/fixtures/TF045/negative/terragrunt.hcl +3 -0
  297. package/src/lint/post-synth/fixtures/TF045/positive/root.hcl +9 -0
  298. package/src/lint/post-synth/fixtures/TF045/positive/terragrunt.hcl +3 -0
  299. package/src/lint/post-synth/fixtures/TF045/unit-only/terragrunt.hcl +3 -0
  300. package/src/lint/post-synth/fixtures/estate-2284/clean/main.tf +132 -0
  301. package/src/lint/post-synth/fixtures/estate-2284/violating/main.tf +112 -0
  302. package/src/lint/post-synth/flat-attributes.ts +146 -0
  303. package/src/lint/post-synth/index.ts +32 -0
  304. package/src/lint/post-synth/module-source.test.ts +42 -1
  305. package/src/lint/post-synth/module-source.ts +56 -1
  306. package/src/lint/post-synth/terragrunt.ts +76 -0
  307. package/src/lint/post-synth/tf002.ts +1 -1
  308. package/src/lint/post-synth/tf030.test.ts +219 -0
  309. package/src/lint/post-synth/tf030.ts +290 -0
  310. package/src/lint/post-synth/tf031.test.ts +229 -0
  311. package/src/lint/post-synth/tf031.ts +370 -0
  312. package/src/lint/post-synth/tf032.test.ts +127 -0
  313. package/src/lint/post-synth/tf032.ts +226 -0
  314. package/src/lint/post-synth/tf033.test.ts +126 -0
  315. package/src/lint/post-synth/tf033.ts +160 -0
  316. package/src/lint/post-synth/tf034.test.ts +71 -0
  317. package/src/lint/post-synth/tf034.ts +63 -0
  318. package/src/lint/post-synth/tf035.test.ts +68 -0
  319. package/src/lint/post-synth/tf035.ts +74 -0
  320. package/src/lint/post-synth/tf036.test.ts +87 -0
  321. package/src/lint/post-synth/tf036.ts +119 -0
  322. package/src/lint/post-synth/tf037.test.ts +88 -0
  323. package/src/lint/post-synth/tf037.ts +101 -0
  324. package/src/lint/post-synth/tf038.test.ts +51 -0
  325. package/src/lint/post-synth/tf038.ts +71 -0
  326. package/src/lint/post-synth/tf039.test.ts +40 -0
  327. package/src/lint/post-synth/tf039.ts +64 -0
  328. package/src/lint/post-synth/tf040.test.ts +55 -0
  329. package/src/lint/post-synth/tf040.ts +76 -0
  330. package/src/lint/post-synth/tf041.test.ts +50 -0
  331. package/src/lint/post-synth/tf041.ts +56 -0
  332. package/src/lint/post-synth/tf042.test.ts +19 -0
  333. package/src/lint/post-synth/tf042.ts +42 -0
  334. package/src/lint/post-synth/tf043.test.ts +65 -0
  335. package/src/lint/post-synth/tf043.ts +49 -0
  336. package/src/lint/post-synth/tf044.test.ts +27 -0
  337. package/src/lint/post-synth/tf044.ts +51 -0
  338. package/src/lint/post-synth/tf045.test.ts +30 -0
  339. package/src/lint/post-synth/tf045.ts +47 -0
  340. package/src/op/activities/index.ts +4 -0
  341. package/src/op/activities/pin-rollout.ts +77 -0
  342. package/src/op/activities/terraform.test.ts +13 -0
  343. package/src/op/activities/terraform.ts +46 -86
  344. package/src/op/activity-contracts.test.ts +4 -1
  345. package/src/op/activity-contracts.ts +42 -0
  346. package/src/op/builders.ts +13 -0
  347. package/src/pin/bundle.test.ts +53 -0
  348. package/src/pin/edit-ts.test.ts +39 -0
  349. package/src/pin/edit-ts.ts +77 -0
  350. package/src/pin/edit.test.ts +199 -0
  351. package/src/pin/edit.ts +157 -0
  352. package/src/pin/forge.ts +85 -0
  353. package/src/pin/index.ts +22 -0
  354. package/src/pin/rollout.test.ts +232 -0
  355. package/src/pin/rollout.ts +451 -0
  356. package/src/pin/scan.ts +309 -0
  357. package/src/pin/source.ts +206 -0
  358. package/src/pin/waves.test.ts +101 -0
  359. package/src/pin/waves.ts +125 -0
  360. package/src/plan-digest.ts +99 -0
  361. package/src/plan-summary.test.ts +154 -0
  362. package/src/plugin.ts +25 -2
  363. package/src/terragrunt/affected.acceptance.test.ts +83 -0
  364. package/src/terragrunt/affected.test.ts +177 -0
  365. package/src/terragrunt/affected.ts +348 -0
  366. package/src/terragrunt/index.ts +11 -0
  367. package/src/terragrunt/mocks.acceptance.test.ts +105 -0
  368. package/src/terragrunt/mocks.test.ts +309 -0
  369. package/src/terragrunt/mocks.ts +324 -0
  370. package/src/terragrunt/run.ts +369 -0
  371. package/src/terragrunt/terragrunt.acceptance.test.ts +122 -0
  372. package/src/terragrunt/terragrunt.test.ts +332 -0
  373. package/src/terragrunt/units.ts +235 -0
  374. package/src/terragrunt/wave.ts +181 -0
@@ -0,0 +1,101 @@
1
+ /**
2
+ * TF037: an ECR repository lets an image tag be repointed (chant #2288, epic
3
+ * #2284).
4
+ *
5
+ * The Terraform counterpart of the aws lexicon's WAW054, written natively.
6
+ *
7
+ * Absence is insecure for this resource, and the rule reports it.
8
+ * `aws_ecr_repository.image_tag_mutability` (provider
9
+ * `internal/service/ecr/repository.go`, v6.67.0) is optional with
10
+ * `Default: MUTABLE`, so a repository that does not set it lets anyone with
11
+ * push access move a tag (`prod`, `v1.4.2`) to different image content after
12
+ * it was deployed, scanned or signed.
13
+ *
14
+ * Provider v6 accepts four values (AWS added the two `_WITH_EXCLUSION` modes
15
+ * in 2025), and the rule reads them as follows:
16
+ *
17
+ * - `IMMUTABLE`: secure.
18
+ * - `IMMUTABLE_WITH_EXCLUSION`: secure. Tags matching an
19
+ * `image_tag_mutability_exclusion_filter` stay mutable, a written-down
20
+ * exception such as `latest`. A filter that is nothing but `*` excludes
21
+ * every tag, so it is a finding; a filter from an expression is not
22
+ * determined.
23
+ * - `MUTABLE`, absent, and `MUTABLE_WITH_EXCLUSION` (every tag mutable except
24
+ * those the filters name): a finding.
25
+ * - an expression: not determined.
26
+ *
27
+ * Scope: root and child modules alike (#2112).
28
+ */
29
+
30
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
31
+ import type { TerraformBlock } from "./blocks";
32
+ import { finding, nestedBodies, notDetermined, readString, resourcesOfType } from "./flat-attributes";
33
+
34
+ const ID = "TF037";
35
+
36
+ const FIX =
37
+ 'Set `image_tag_mutability = "IMMUTABLE"` and push a new tag for each build, or `"IMMUTABLE_WITH_EXCLUSION"` with ' +
38
+ "an `image_tag_mutability_exclusion_filter` for the few moving tags (`latest`) that must stay mutable.";
39
+
40
+ const TAIL = "TF037 does not evaluate expressions, so it cannot tell whether this repository's tags are immutable.";
41
+
42
+ /** A diagnostic for an `IMMUTABLE_WITH_EXCLUSION` repository, or nothing. */
43
+ function checkExclusions(block: TerraformBlock): PostSynthDiagnostic | undefined {
44
+ for (const [i, f] of nestedBodies(block.body, "image_tag_mutability_exclusion_filter").entries()) {
45
+ const filter = readString(f, "filter");
46
+ if (filter.kind === "unknown") {
47
+ return notDetermined(ID, block, `exclusion filter ${i + 1}: ${filter.reason}`, TAIL);
48
+ }
49
+ if (filter.kind === "known" && /^\*+$/.test(filter.value)) {
50
+ return finding(
51
+ ID,
52
+ "error",
53
+ block,
54
+ `is \`IMMUTABLE_WITH_EXCLUSION\`, but exclusion filter ${i + 1} is "${filter.value}", which matches every tag, ` +
55
+ `so every tag stays mutable. ${FIX}`,
56
+ );
57
+ }
58
+ }
59
+ if (nestedBodies(block.body, "dynamic").some((d) => d.image_tag_mutability_exclusion_filter !== undefined)) {
60
+ return notDetermined(ID, block, 'has a `dynamic "image_tag_mutability_exclusion_filter"` block', TAIL);
61
+ }
62
+ return undefined;
63
+ }
64
+
65
+ export const tf037: PostSynthCheck = {
66
+ id: "TF037",
67
+ description: "ECR repository allows mutable image tags",
68
+
69
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
70
+ const out: PostSynthDiagnostic[] = [];
71
+ for (const block of resourcesOfType(ctx, "aws_ecr_repository")) {
72
+ const mode = readString(block.body, "image_tag_mutability");
73
+ if (mode.kind === "unknown") {
74
+ out.push(notDetermined(ID, block, mode.reason, TAIL));
75
+ continue;
76
+ }
77
+ if (mode.kind === "known" && mode.value === "IMMUTABLE") continue;
78
+ if (mode.kind === "known" && mode.value === "IMMUTABLE_WITH_EXCLUSION") {
79
+ const d = checkExclusions(block);
80
+ if (d) out.push(d);
81
+ continue;
82
+ }
83
+ const how =
84
+ mode.kind === "absent"
85
+ ? "does not set `image_tag_mutability`, and the provider default is `MUTABLE`"
86
+ : mode.value === "MUTABLE_WITH_EXCLUSION"
87
+ ? "is `MUTABLE_WITH_EXCLUSION`, so every tag the exclusion filters do not name stays mutable"
88
+ : `sets \`image_tag_mutability = "${mode.value}"\``;
89
+ out.push(
90
+ finding(
91
+ ID,
92
+ "error",
93
+ block,
94
+ `${how}: a pushed tag can later be repointed at different image content, so what was deployed, scanned or ` +
95
+ `signed under that tag is no longer what it names. ${FIX}`,
96
+ ),
97
+ );
98
+ }
99
+ return out;
100
+ },
101
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * TF038: an `oci://` module source names no tag and no digest, or a mutable
3
+ * tag.
4
+ *
5
+ * OpenTofu resolves an OCI module source with no `tag` to the `latest` tag
6
+ * (https://opentofu.org/docs/language/modules/sources/), so an unpinned source
7
+ * and `?tag=latest` are the same thing: a push to the registry changes what
8
+ * the root provisions with no diff to review. A digest, or an exact version
9
+ * tag, holds it. `classifyModuleSource` (`./module-source.ts`) reads the tag
10
+ * and digest from either spelling.
11
+ *
12
+ * A warning rather than an error: a registry can make a version tag
13
+ * immutable, and a source that names `?tag=1.4.0` is read as pinned here
14
+ * whether or not the registry enforces that. A digest is the only pin the
15
+ * registry cannot move, which the message says. A source that names a digest
16
+ * is never flagged, whatever tag sits beside it.
17
+ *
18
+ * Scope: root and child modules alike (#2112), same as TF004 and TF005.
19
+ */
20
+
21
+ import type {
22
+ PostSynthCheck,
23
+ PostSynthContext,
24
+ PostSynthDiagnostic,
25
+ } from "@intentius/chant/lint/post-synth";
26
+ import { isResourceDeclarable } from "@intentius/chant/declarable";
27
+ import { MODULE_TYPE, type BlockBody } from "../../hcl/parse";
28
+ import { classifyModuleSource, isMutableOciTag } from "./module-source";
29
+
30
+ export const tf038: PostSynthCheck = {
31
+ id: "TF038",
32
+ description: "OCI module source has no tag or digest, or a mutable tag",
33
+
34
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
35
+ const diagnostics: PostSynthDiagnostic[] = [];
36
+
37
+ for (const [key, entity] of ctx.entities) {
38
+ if (entity.entityType !== MODULE_TYPE || !isResourceDeclarable(entity)) continue;
39
+ const props = entity.props as { address?: unknown; body?: unknown };
40
+ const body = (typeof props.body === "object" && props.body !== null ? props.body : {}) as BlockBody;
41
+ const source = typeof body.source === "string" ? body.source : undefined;
42
+ if (source === undefined) continue;
43
+
44
+ const classified = classifyModuleSource(source);
45
+ if (classified.kind !== "oci" || classified.digest) continue;
46
+
47
+ const address = typeof props.address === "string" ? props.address : key;
48
+ let message: string | undefined;
49
+ if (!classified.tag) {
50
+ message =
51
+ `Module "${address}" sources "${source}" with no tag or digest, so OpenTofu pulls the \`latest\` tag. ` +
52
+ "Pin it to a digest (`?digest=sha256:...`) or an exact version tag (`?tag=1.4.0`).";
53
+ } else if (isMutableOciTag(classified.tag)) {
54
+ message =
55
+ `Module "${address}" sources "${source}" with the mutable tag "${classified.tag}". ` +
56
+ "Pin it to a digest (`?digest=sha256:...`) or an exact version tag (`?tag=1.4.0`).";
57
+ }
58
+ if (!message) continue;
59
+
60
+ diagnostics.push({
61
+ checkId: "TF038",
62
+ severity: "warning",
63
+ message,
64
+ entity: key,
65
+ lexicon: "terraform",
66
+ });
67
+ }
68
+
69
+ return diagnostics;
70
+ },
71
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * TF039: a registry module's `version` is a range, not an exact version.
3
+ *
4
+ * TF004 flags a registry module with no `version`; a `version` of `~> 1.4`,
5
+ * `>= 1.4` or `>= 1.0, < 2.0` passes it, yet an upstream release inside the
6
+ * range changes what the root provisions with no diff to review. This rule is
7
+ * for projects that pin modules to one version (`1.4.0` or `= 1.4.0`).
8
+ *
9
+ * Off by default: it is a `report-only` catalog entry, so the `recommended`
10
+ * preset leaves it out and `lint.presets: { terraform: "all" }` (or a
11
+ * `lint.rules` entry for TF039) turns it on. Ranges are common and often
12
+ * intended, so a default warning would be noise for most roots. It is a
13
+ * separate rule from TF004 because a post-synth check receives no options
14
+ * (`PostSynthCheck.check(ctx)`), while the preset mechanism already carries
15
+ * exactly this on/off choice per rule id (#3190).
16
+ *
17
+ * A module that has no `version` is TF004's finding and is skipped here.
18
+ *
19
+ * Scope: root and child modules alike (#2112).
20
+ */
21
+
22
+ import type {
23
+ PostSynthCheck,
24
+ PostSynthContext,
25
+ PostSynthDiagnostic,
26
+ } from "@intentius/chant/lint/post-synth";
27
+ import { isResourceDeclarable } from "@intentius/chant/declarable";
28
+ import { MODULE_TYPE, type BlockBody } from "../../hcl/parse";
29
+ import { classifyModuleSource, isExactVersionConstraint } from "./module-source";
30
+
31
+ export const tf039: PostSynthCheck = {
32
+ id: "TF039",
33
+ description: "Registry module version is a range, not an exact version",
34
+
35
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
36
+ const diagnostics: PostSynthDiagnostic[] = [];
37
+
38
+ for (const [key, entity] of ctx.entities) {
39
+ if (entity.entityType !== MODULE_TYPE || !isResourceDeclarable(entity)) continue;
40
+ const props = entity.props as { address?: unknown; body?: unknown };
41
+ const body = (typeof props.body === "object" && props.body !== null ? props.body : {}) as BlockBody;
42
+ const source = typeof body.source === "string" ? body.source : undefined;
43
+ if (source === undefined || classifyModuleSource(source).kind !== "registry") continue;
44
+
45
+ const version = body.version;
46
+ if (typeof version !== "string" || version.trim() === "") continue;
47
+ if (isExactVersionConstraint(version)) continue;
48
+
49
+ const address = typeof props.address === "string" ? props.address : key;
50
+ diagnostics.push({
51
+ checkId: "TF039",
52
+ severity: "warning",
53
+ message:
54
+ `Module "${address}" sources "${source}" with the version range "${version}". ` +
55
+ "A release inside the range changes what the root provisions with no diff to review. " +
56
+ 'Pin an exact version (`version = "1.4.0"`).',
57
+ entity: key,
58
+ lexicon: "terraform",
59
+ });
60
+ }
61
+
62
+ return diagnostics;
63
+ },
64
+ };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * TF040: a root that uses providers has no `.terraform.lock.hcl`.
3
+ *
4
+ * The lock file records the provider versions and hashes `terraform init`
5
+ * selected. Without it, each `init` resolves `required_providers` constraints
6
+ * afresh, so a provider release changes a plan with no diff. None of
7
+ * TF001 to TF029 looks at it.
8
+ *
9
+ * "Committed" is decided by presence: the file sits beside the root's `.tf`
10
+ * files in the source tree being parsed (`props.lockFile`, stamped by
11
+ * `parseTerraformRootDir` and by the local audit path). Whether git tracks it
12
+ * is not asked, so a lock file that is present but gitignored counts as
13
+ * committed. A parse with no directory to look in (a fetched repository,
14
+ * inline source) leaves `lockFile` unset and the rule reports nothing: not
15
+ * determined, not clean.
16
+ *
17
+ * A root that implies no provider (no `provider` block and no resource or data
18
+ * type) gets no lock file from `init`, so it is skipped, as is a live
19
+ * choudoufu root, which runs no `init`. One diagnostic per root, anchored on
20
+ * the first block that implies a provider.
21
+ *
22
+ * Off by default in both places: the `report-only` tier keeps it out of a
23
+ * build's `recommended` preset, and `auditOptIn` keeps it out of `chant audit`.
24
+ * Many estates run `init` in CI and never commit the file.
25
+ *
26
+ * Scope: root modules only (#2112); a child module has no lock file of its own.
27
+ */
28
+
29
+ import type {
30
+ PostSynthCheck,
31
+ PostSynthContext,
32
+ PostSynthDiagnostic,
33
+ } from "@intentius/chant/lint/post-synth";
34
+ import { isResourceDeclarable } from "@intentius/chant/declarable";
35
+ import { LOCK_FILENAME } from "../../hcl/parse";
36
+ import { isRootScoped } from "./scope";
37
+ import { impliedProviders } from "./tf002";
38
+
39
+ export const tf040: PostSynthCheck = {
40
+ id: "TF040",
41
+ description: "Root has no committed .terraform.lock.hcl",
42
+ // `chant audit` runs every rule, report-only ones included, so without this a
43
+ // new rule would change every project's audit output. A `lint.rules` entry
44
+ // for TF040 turns it on in the audit as well as in a build (#3190).
45
+ auditOptIn: true,
46
+
47
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
48
+ const diagnostics: PostSynthDiagnostic[] = [];
49
+ const missing = new Set<string>();
50
+
51
+ for (const entity of ctx.entities.values()) {
52
+ if (!isResourceDeclarable(entity) || !isRootScoped(entity)) continue;
53
+ const props = entity.props as { root?: unknown; lockFile?: unknown; mode?: unknown };
54
+ if (props.lockFile !== false || props.mode === "live" || typeof props.root !== "string") continue;
55
+ missing.add(props.root);
56
+ }
57
+
58
+ for (const root of [...missing].sort()) {
59
+ const implied = impliedProviders(ctx.entities, root);
60
+ if (implied.size === 0) continue;
61
+ const names = [...implied.keys()].sort();
62
+ diagnostics.push({
63
+ checkId: "TF040",
64
+ severity: "warning",
65
+ message:
66
+ `Root module "${root}" uses ${names.length === 1 ? "provider" : "providers"} ${names.map((n) => `"${n}"`).join(", ")} ` +
67
+ `but has no ${LOCK_FILENAME} beside its .tf files. Run \`terraform init\` and commit the file, ` +
68
+ "so every init selects the same provider versions.",
69
+ entity: implied.get(names[0]),
70
+ lexicon: "terraform",
71
+ });
72
+ }
73
+
74
+ return diagnostics;
75
+ },
76
+ };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * TF041: a Terragrunt `dependency` has `mock_outputs` and lets them stand in
3
+ * for `apply`.
4
+ *
5
+ * `mock_outputs` is what a dependency returns when it has no outputs yet.
6
+ * `mock_outputs_allowed_terraform_commands` limits which commands may use
7
+ * them. Terragrunt reads a missing list and an empty list the same way, as no
8
+ * limit (`shouldReturnMockOutputs` in `pkg/config/dependency.go`, v1.1.6:
9
+ * `nil || len == 0 || slices.Contains(list, command)`). So a dependency with
10
+ * mocks and no list, or a list that names `apply`, can apply the mock values
11
+ * to real state when the upstream unit has not been applied, and the apply
12
+ * reports success. The usual list is `["validate", "plan"]`.
13
+ *
14
+ * A list that is an expression (`local.mock_commands`) is not determined and
15
+ * passes. A dependency with `enabled = false` returns its mocks whatever the
16
+ * list says; that is a different decision and is not reported here.
17
+ */
18
+
19
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
20
+ import { TERRAGRUNT_DEPENDENCY_TYPE } from "../../hcl/parse";
21
+ import { isExpression, terragruntEntities } from "./terragrunt";
22
+
23
+ export const tf041: PostSynthCheck = {
24
+ id: "TF041",
25
+ description: "Terragrunt dependency lets mock_outputs stand in for apply",
26
+
27
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
28
+ const diagnostics: PostSynthDiagnostic[] = [];
29
+ for (const dep of terragruntEntities(ctx.entities, TERRAGRUNT_DEPENDENCY_TYPE)) {
30
+ if (dep.body.mock_outputs === undefined) continue;
31
+ const allowed = dep.body.mock_outputs_allowed_terraform_commands;
32
+ if (isExpression(allowed)) continue;
33
+
34
+ let problem: string | undefined;
35
+ if (allowed === undefined || (Array.isArray(allowed) && allowed.length === 0)) {
36
+ problem =
37
+ "sets no `mock_outputs_allowed_terraform_commands`, and Terragrunt reads a missing or empty list as every command";
38
+ } else if (Array.isArray(allowed) && allowed.includes("apply")) {
39
+ problem = 'lists "apply" in `mock_outputs_allowed_terraform_commands`';
40
+ }
41
+ if (problem === undefined) continue;
42
+
43
+ diagnostics.push({
44
+ checkId: "TF041",
45
+ severity: "warning",
46
+ message:
47
+ `Dependency "${dep.address.replace(/^dependency\./, "")}" in ${dep.file} sets \`mock_outputs\` and ${problem}. ` +
48
+ "An apply that runs before the upstream unit is applied writes the mock values to real state. " +
49
+ 'Set `mock_outputs_allowed_terraform_commands = ["validate", "plan"]`.',
50
+ entity: dep.key,
51
+ lexicon: "terraform",
52
+ });
53
+ }
54
+ return diagnostics;
55
+ },
56
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * TF042: a Terragrunt `dependency` sets `skip_outputs = true` and
3
+ * `mock_outputs`.
4
+ *
5
+ * With `skip_outputs = true` Terragrunt never reads the upstream unit's
6
+ * outputs (`shouldGetOutputs` in `pkg/config/dependency.go`, v1.1.6), so the
7
+ * only values the dependency can return are the mocks. Every plan and apply
8
+ * the mocks are allowed for runs on them, however far the upstream unit has
9
+ * been applied. The pair is sometimes meant, to break a cycle or to avoid
10
+ * reading state, and then the mock values are the configuration; that is
11
+ * worth writing as inputs, which a reader of the unit can see.
12
+ *
13
+ * Only a literal `skip_outputs = true` is reported. A `skip_outputs` built
14
+ * from an expression is not determined.
15
+ */
16
+
17
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
18
+ import { TERRAGRUNT_DEPENDENCY_TYPE } from "../../hcl/parse";
19
+ import { terragruntEntities } from "./terragrunt";
20
+
21
+ export const tf042: PostSynthCheck = {
22
+ id: "TF042",
23
+ description: "Terragrunt dependency sets skip_outputs together with mock_outputs",
24
+
25
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
26
+ const diagnostics: PostSynthDiagnostic[] = [];
27
+ for (const dep of terragruntEntities(ctx.entities, TERRAGRUNT_DEPENDENCY_TYPE)) {
28
+ if (dep.body.skip_outputs !== true || dep.body.mock_outputs === undefined) continue;
29
+ diagnostics.push({
30
+ checkId: "TF042",
31
+ severity: "warning",
32
+ message:
33
+ `Dependency "${dep.address.replace(/^dependency\./, "")}" in ${dep.file} sets \`skip_outputs = true\` with \`mock_outputs\`. ` +
34
+ "Terragrunt then never reads the upstream unit's outputs, so every plan and apply runs on the mock values. " +
35
+ "Drop `skip_outputs`, or pass the values as `inputs` so they are visible as configuration.",
36
+ entity: dep.key,
37
+ lexicon: "terraform",
38
+ });
39
+ }
40
+ return diagnostics;
41
+ },
42
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * TF043: a Terragrunt unit's `terraform.source` names no version.
3
+ *
4
+ * A git source with no `?ref=` follows the default branch, a `tfr://` source
5
+ * with no `?version=` follows the registry's latest release, and an `oci://`
6
+ * source with no tag or digest pulls `latest`. A push or a release changes
7
+ * what the unit provisions with no diff to review. TF005 and TF038 do the same
8
+ * for `module` blocks; a Terragrunt unit has no `module` block, its source is
9
+ * the `source` argument of the `terraform` block.
10
+ *
11
+ * A local path and a source built from an expression (`${local.base}//x`) are
12
+ * not determined and pass. A mutable `?ref=main` is not judged
13
+ * here: the rule asks only whether a version is named.
14
+ */
15
+
16
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
17
+ import { TERRAGRUNT_SOURCE_TYPE } from "../../hcl/parse";
18
+ import { classifyTerragruntSource, terragruntEntities } from "./terragrunt";
19
+
20
+ const FIX: Record<string, string> = {
21
+ git: "Add `?ref=` with a tag or commit SHA.",
22
+ tfr: "Add `?version=` with an exact version.",
23
+ oci: "Add `?digest=sha256:...` or `?tag=` with an exact version tag.",
24
+ };
25
+
26
+ export const tf043: PostSynthCheck = {
27
+ id: "TF043",
28
+ description: "Terragrunt terraform.source names no version (git ref, tfr version or oci tag)",
29
+
30
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
31
+ const diagnostics: PostSynthDiagnostic[] = [];
32
+ for (const block of terragruntEntities(ctx.entities, TERRAGRUNT_SOURCE_TYPE)) {
33
+ const source = block.body.source;
34
+ if (typeof source !== "string") continue;
35
+ const classified = classifyTerragruntSource(source);
36
+ if (classified.pinned !== false) continue;
37
+ diagnostics.push({
38
+ checkId: "TF043",
39
+ severity: "warning",
40
+ message:
41
+ `The \`terraform\` block in ${block.file} sources "${source}" with no version, so a push or a release changes the unit with no diff to review. ` +
42
+ FIX[classified.kind],
43
+ entity: block.key,
44
+ lexicon: "terraform",
45
+ });
46
+ }
47
+ return diagnostics;
48
+ },
49
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * TF044: a Terragrunt config keeps state in a local backend.
3
+ *
4
+ * Read from `remote_state { backend = "local" }` and from a `generate` block
5
+ * whose `contents` declare `backend "local"`. State on the runner's disk is
6
+ * gone when the job ends, a second job cannot read what the first applied, and
7
+ * a git-range run, which checks out each side in a temporary directory, never
8
+ * sees state at all. A shared backend (S3, GCS, azurerm, a Terraform HTTP
9
+ * backend) holds it.
10
+ *
11
+ * A backend named by an expression is not determined and passes. A local
12
+ * backend is sometimes right for a throwaway sandbox; suppress the rule there
13
+ * with `# chant-ignore TF044`.
14
+ */
15
+
16
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
17
+ import { TERRAGRUNT_GENERATE_TYPE, TERRAGRUNT_REMOTE_STATE_TYPE } from "../../hcl/parse";
18
+ import { terragruntEntities } from "./terragrunt";
19
+
20
+ const LOCAL_BACKEND_BLOCK = /\bbackend\s+"local"/;
21
+
22
+ export const tf044: PostSynthCheck = {
23
+ id: "TF044",
24
+ description: "Terragrunt config keeps state in a local backend",
25
+
26
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
27
+ const diagnostics: PostSynthDiagnostic[] = [];
28
+ const report = (key: string, file: string, how: string): void => {
29
+ diagnostics.push({
30
+ checkId: "TF044",
31
+ severity: "warning",
32
+ message:
33
+ `${how} in ${file} keeps state in a local backend. The state lives on the runner's disk, so a later job cannot read it ` +
34
+ "and a git-range run, which checks out each side in a temporary directory, never sees it. Use a shared backend such as S3 or GCS.",
35
+ entity: key,
36
+ lexicon: "terraform",
37
+ });
38
+ };
39
+
40
+ for (const block of terragruntEntities(ctx.entities, TERRAGRUNT_REMOTE_STATE_TYPE)) {
41
+ if (block.body.backend === "local") report(block.key, block.file, "`remote_state` sets `backend = \"local\"`");
42
+ }
43
+ for (const block of terragruntEntities(ctx.entities, TERRAGRUNT_GENERATE_TYPE)) {
44
+ const contents = block.body.contents;
45
+ if (typeof contents === "string" && LOCAL_BACKEND_BLOCK.test(contents)) {
46
+ report(block.key, block.file, `\`generate "${block.address.replace(/^generate\./, "")}"\` writes a \`backend "local"\` block`);
47
+ }
48
+ }
49
+ return diagnostics;
50
+ },
51
+ };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * TF045: no Terragrunt config sets `terragrunt_version_constraint`.
3
+ *
4
+ * The attribute makes Terragrunt refuse to run on a release outside the range.
5
+ * Without it each machine and each CI image runs whatever Terragrunt it
6
+ * installed, and a behaviour change between releases reaches a plan with no
7
+ * diff. It is usually set once, in the root config every unit includes.
8
+ *
9
+ * The rule looks at the whole set of configs in the scan and reports once. It
10
+ * reports only when the set holds a config that includes no other file (the
11
+ * root config, or a self-contained unit) and none of the configs sets the
12
+ * attribute. A set made only of units that include a parent it did not read,
13
+ * such as one unit directory passed alone, is not determined: the parent may
14
+ * set it. The finding is anchored on `root.hcl` when the set has one.
15
+ *
16
+ * Off by default: the `report-only` tier keeps it out of the `recommended`
17
+ * preset, since many repos pin Terragrunt in the toolchain (`.tool-versions`,
18
+ * a CI image) rather than in config.
19
+ */
20
+
21
+ import type { PostSynthCheck, PostSynthContext, PostSynthDiagnostic } from "@intentius/chant/lint/post-synth";
22
+ import { TERRAGRUNT_CONFIG_TYPE } from "../../hcl/parse";
23
+ import { terragruntEntities } from "./terragrunt";
24
+
25
+ export const tf045: PostSynthCheck = {
26
+ id: "TF045",
27
+ description: "No Terragrunt config sets terragrunt_version_constraint",
28
+
29
+ check(ctx: PostSynthContext): PostSynthDiagnostic[] {
30
+ const configs = terragruntEntities(ctx.entities, TERRAGRUNT_CONFIG_TYPE);
31
+ if (configs.some((c) => c.body.terragrunt_version_constraint !== undefined)) return [];
32
+ const tops = configs.filter((c) => Array.isArray(c.body.includes) && c.body.includes.length === 0);
33
+ if (tops.length === 0) return [];
34
+ const anchor = [...tops].sort((a, b) => Number(b.file === "root.hcl") - Number(a.file === "root.hcl") || a.key.localeCompare(b.key))[0];
35
+ return [
36
+ {
37
+ checkId: "TF045",
38
+ severity: "warning",
39
+ message:
40
+ `No Terragrunt config sets \`terragrunt_version_constraint\` (${anchor.file} is the top config read). ` +
41
+ 'Set it once in the root config, for example `terragrunt_version_constraint = ">= 1.1.0"`, so every machine runs a release the repo was tested with.',
42
+ entity: anchor.key,
43
+ lexicon: "terraform",
44
+ },
45
+ ];
46
+ },
47
+ };