@intentius/chant-lexicon-terraform 0.124.54 → 0.124.56
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.
- package/README.md +7 -4
- package/dist/ci-setup.d.ts +11 -0
- package/dist/ci-setup.d.ts.map +1 -0
- package/dist/ci-setup.js +41 -0
- package/dist/components/capability-plugin.d.ts +40 -6
- package/dist/components/capability-plugin.d.ts.map +1 -1
- package/dist/components/capability-plugin.js +174 -30
- package/dist/components/compose-group.d.ts +1 -1
- package/dist/components/compose-group.d.ts.map +1 -1
- package/dist/components/compose-group.js +1 -1
- package/dist/components/release-inputs.d.ts +29 -0
- package/dist/components/release-inputs.d.ts.map +1 -0
- package/dist/components/release-inputs.js +57 -0
- package/dist/components/trace-facts.d.ts +16 -0
- package/dist/components/trace-facts.d.ts.map +1 -0
- package/dist/components/trace-facts.js +19 -0
- package/dist/cone.d.ts +53 -0
- package/dist/cone.d.ts.map +1 -0
- package/dist/cone.js +119 -0
- package/dist/cost-hold.d.ts +27 -0
- package/dist/cost-hold.d.ts.map +1 -0
- package/dist/cost-hold.js +21 -0
- package/dist/drift-rows.d.ts +61 -0
- package/dist/drift-rows.d.ts.map +1 -0
- package/dist/drift-rows.js +108 -0
- package/dist/exit-codes.d.ts +55 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +48 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/integrity.json +7 -4
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/audit-catalog.js +27 -3
- package/dist/lint/audit-lineage.d.ts +14 -2
- package/dist/lint/audit-lineage.d.ts.map +1 -1
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/post-synth/index.js +4 -0
- package/dist/lint/post-synth/record-store.d.ts +54 -0
- package/dist/lint/post-synth/record-store.d.ts.map +1 -0
- package/dist/lint/post-synth/record-store.js +104 -0
- package/dist/lint/post-synth/tf001.d.ts +2 -2
- package/dist/lint/post-synth/tf001.js +2 -2
- package/dist/lint/post-synth/tf024.d.ts +35 -11
- package/dist/lint/post-synth/tf024.d.ts.map +1 -1
- package/dist/lint/post-synth/tf024.js +92 -20
- package/dist/lint/post-synth/tf046.d.ts +64 -0
- package/dist/lint/post-synth/tf046.d.ts.map +1 -0
- package/dist/lint/post-synth/tf046.js +175 -0
- package/dist/lint/post-synth/tf047.d.ts +36 -0
- package/dist/lint/post-synth/tf047.d.ts.map +1 -0
- package/dist/lint/post-synth/tf047.js +94 -0
- package/dist/lock-rows.d.ts +36 -0
- package/dist/lock-rows.d.ts.map +1 -0
- package/dist/lock-rows.js +60 -0
- package/dist/lock-timeout.d.ts +22 -0
- package/dist/lock-timeout.d.ts.map +1 -0
- package/dist/lock-timeout.js +32 -0
- package/dist/manifest.json +1 -1
- package/dist/module-catalog/index.d.ts +69 -0
- package/dist/module-catalog/index.d.ts.map +1 -0
- package/dist/module-catalog/index.js +110 -0
- package/dist/module-catalog/refresh-cli.d.ts +4 -0
- package/dist/module-catalog/refresh-cli.d.ts.map +1 -0
- package/dist/module-catalog/refresh-cli.js +64 -0
- package/dist/module-catalog/static-tier.d.ts +6 -0
- package/dist/module-catalog/static-tier.d.ts.map +1 -0
- package/dist/module-catalog/static-tier.js +1650 -0
- package/dist/module-catalog/types.d.ts +65 -0
- package/dist/module-catalog/types.d.ts.map +1 -0
- package/dist/module-catalog/types.js +33 -0
- package/dist/okf/index.md +3 -1
- package/dist/okf/rules/TF024.md +2 -2
- package/dist/okf/rules/TF046.md +11 -0
- package/dist/okf/rules/TF047.md +11 -0
- package/dist/op/activities/terraform.d.ts +29 -0
- package/dist/op/activities/terraform.d.ts.map +1 -1
- package/dist/op/activities/terraform.js +19 -4
- package/dist/pin/consumers.d.ts +35 -0
- package/dist/pin/consumers.d.ts.map +1 -0
- package/dist/pin/consumers.js +70 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +5 -0
- package/dist/registry/address.d.ts +63 -0
- package/dist/registry/address.d.ts.map +1 -0
- package/dist/registry/address.js +65 -0
- package/dist/registry/catalog-read.d.ts +14 -0
- package/dist/registry/catalog-read.d.ts.map +1 -0
- package/dist/registry/catalog-read.js +58 -0
- package/dist/registry/deprecated.d.ts +37 -0
- package/dist/registry/deprecated.d.ts.map +1 -0
- package/dist/registry/deprecated.js +43 -0
- package/dist/registry/docs.d.ts +96 -0
- package/dist/registry/docs.d.ts.map +1 -0
- package/dist/registry/docs.js +210 -0
- package/dist/registry/edge/edge.d.ts +46 -0
- package/dist/registry/edge/edge.d.ts.map +1 -0
- package/dist/registry/edge/edge.js +194 -0
- package/dist/registry/edge/index.d.ts +11 -0
- package/dist/registry/edge/index.d.ts.map +1 -0
- package/dist/registry/edge/index.js +10 -0
- package/dist/registry/edge/lambda-edge.d.ts +76 -0
- package/dist/registry/edge/lambda-edge.d.ts.map +1 -0
- package/dist/registry/edge/lambda-edge.js +95 -0
- package/dist/registry/edge/sigv4-web.d.ts +33 -0
- package/dist/registry/edge/sigv4-web.d.ts.map +1 -0
- package/dist/registry/edge/sigv4-web.js +56 -0
- package/dist/registry/edge/token-source.d.ts +73 -0
- package/dist/registry/edge/token-source.d.ts.map +1 -0
- package/dist/registry/edge/token-source.js +115 -0
- package/dist/registry/edge/worker.d.ts +45 -0
- package/dist/registry/edge/worker.d.ts.map +1 -0
- package/dist/registry/edge/worker.js +26 -0
- package/dist/registry/handler.d.ts +25 -0
- package/dist/registry/handler.d.ts.map +1 -0
- package/dist/registry/handler.js +75 -0
- package/dist/registry/headers-file.d.ts +21 -0
- package/dist/registry/headers-file.d.ts.map +1 -0
- package/dist/registry/headers-file.js +57 -0
- package/dist/registry/index.d.ts +31 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +30 -0
- package/dist/registry/mirror-paths.d.ts +9 -0
- package/dist/registry/mirror-paths.d.ts.map +1 -0
- package/dist/registry/mirror-paths.js +8 -0
- package/dist/registry/mirror.d.ts +130 -0
- package/dist/registry/mirror.d.ts.map +1 -0
- package/dist/registry/mirror.js +319 -0
- package/dist/registry/proxies.d.ts +73 -0
- package/dist/registry/proxies.d.ts.map +1 -0
- package/dist/registry/proxies.js +111 -0
- package/dist/registry/reader.d.ts +57 -0
- package/dist/registry/reader.d.ts.map +1 -0
- package/dist/registry/reader.js +198 -0
- package/dist/registry/semver.d.ts +16 -0
- package/dist/registry/semver.d.ts.map +1 -0
- package/dist/registry/semver.js +24 -0
- package/dist/registry/serve.d.ts +24 -0
- package/dist/registry/serve.d.ts.map +1 -0
- package/dist/registry/serve.js +64 -0
- package/dist/registry/source-forms.d.ts +79 -0
- package/dist/registry/source-forms.d.ts.map +1 -0
- package/dist/registry/source-forms.js +202 -0
- package/dist/registry/targets/artifactory.d.ts +28 -0
- package/dist/registry/targets/artifactory.d.ts.map +1 -0
- package/dist/registry/targets/artifactory.js +206 -0
- package/dist/registry/targets/fake-artifactory.d.ts +30 -0
- package/dist/registry/targets/fake-artifactory.d.ts.map +1 -0
- package/dist/registry/targets/fake-artifactory.js +142 -0
- package/dist/registry/targets/fake-gitlab.d.ts +39 -0
- package/dist/registry/targets/fake-gitlab.d.ts.map +1 -0
- package/dist/registry/targets/fake-gitlab.js +136 -0
- package/dist/registry/targets/fake-hcp.d.ts +50 -0
- package/dist/registry/targets/fake-hcp.d.ts.map +1 -0
- package/dist/registry/targets/fake-hcp.js +202 -0
- package/dist/registry/targets/fake-http.d.ts +31 -0
- package/dist/registry/targets/fake-http.d.ts.map +1 -0
- package/dist/registry/targets/fake-http.js +87 -0
- package/dist/registry/targets/fake-nexus.d.ts +27 -0
- package/dist/registry/targets/fake-nexus.d.ts.map +1 -0
- package/dist/registry/targets/fake-nexus.js +137 -0
- package/dist/registry/targets/gitlab.d.ts +53 -0
- package/dist/registry/targets/gitlab.d.ts.map +1 -0
- package/dist/registry/targets/gitlab.js +187 -0
- package/dist/registry/targets/hcp.d.ts +29 -0
- package/dist/registry/targets/hcp.d.ts.map +1 -0
- package/dist/registry/targets/hcp.js +310 -0
- package/dist/registry/targets/hosted.d.ts +62 -0
- package/dist/registry/targets/hosted.d.ts.map +1 -0
- package/dist/registry/targets/hosted.js +74 -0
- package/dist/registry/targets/index.d.ts +18 -0
- package/dist/registry/targets/index.d.ts.map +1 -0
- package/dist/registry/targets/index.js +17 -0
- package/dist/registry/targets/module-target.d.ts +68 -0
- package/dist/registry/targets/module-target.d.ts.map +1 -0
- package/dist/registry/targets/module-target.js +63 -0
- package/dist/registry/targets/nexus.d.ts +43 -0
- package/dist/registry/targets/nexus.d.ts.map +1 -0
- package/dist/registry/targets/nexus.js +250 -0
- package/dist/registry/targets/zip.d.ts +55 -0
- package/dist/registry/targets/zip.d.ts.map +1 -0
- package/dist/registry/targets/zip.js +278 -0
- package/dist/registry/writer.d.ts +101 -0
- package/dist/registry/writer.d.ts.map +1 -0
- package/dist/registry/writer.js +109 -0
- package/dist/rules/record-store.ts +122 -0
- package/dist/rules/tf001.ts +2 -2
- package/dist/rules/tf024.ts +105 -22
- package/dist/rules/tf046.ts +204 -0
- package/dist/rules/tf047.ts +114 -0
- package/dist/state/azure-blob.d.ts +8 -67
- package/dist/state/azure-blob.d.ts.map +1 -1
- package/dist/state/azure-blob.js +6 -199
- package/dist/state/gcs.d.ts +7 -61
- package/dist/state/gcs.d.ts.map +1 -1
- package/dist/state/gcs.js +5 -222
- package/dist/state/object-store.d.ts +4 -33
- package/dist/state/object-store.d.ts.map +1 -1
- package/dist/state/object-store.js +4 -17
- package/dist/state/s3.d.ts +11 -58
- package/dist/state/s3.d.ts.map +1 -1
- package/dist/state/s3.js +10 -161
- package/dist/state/store.js +2 -2
- package/dist/state-ops.d.ts +255 -0
- package/dist/state-ops.d.ts.map +1 -0
- package/dist/state-ops.js +305 -0
- package/dist/state-reads.d.ts +57 -0
- package/dist/state-reads.d.ts.map +1 -0
- package/dist/state-reads.js +104 -0
- package/dist/used-sources.d.ts +54 -0
- package/dist/used-sources.d.ts.map +1 -0
- package/dist/used-sources.js +157 -0
- package/package.json +19 -3
- package/src/__fixtures__/drift-record/README.md +5 -0
- package/src/__fixtures__/drift-rows/live-root-plan.json +70 -0
- package/src/__fixtures__/drift-rows/refresh-plan.json +61 -0
- package/src/__fixtures__/used-sources/root/extra.tofu +1 -0
- package/src/__fixtures__/used-sources/root/main.tf +31 -0
- package/src/__fixtures__/used-sources/root/modules/net/main.tf +14 -0
- package/src/__fixtures__/used-sources/root/modules/net/versions.tf.json +7 -0
- package/src/__fixtures__/used-sources/unit/terragrunt.hcl +3 -0
- package/src/ci-setup.ts +42 -0
- package/src/components/capability-plugin.test.ts +26 -14
- package/src/components/capability-plugin.ts +185 -31
- package/src/components/compose-group.ts +1 -1
- package/src/components/pr-loop-compose.tofu.e2e.test.ts +1 -1
- package/src/components/pr-loop.tofu.test.ts +1 -1
- package/src/components/release-inputs.ts +69 -0
- package/src/components/trace-facts.test.ts +21 -0
- package/src/components/trace-facts.ts +27 -0
- package/src/cone.ts +138 -0
- package/src/cost-hold.ts +29 -0
- package/src/describe-resources.engine-facts.test.ts +2 -3
- package/src/drift-rows.test.ts +135 -0
- package/src/drift-rows.ts +137 -0
- package/src/exit-codes.test.ts +23 -0
- package/src/exit-codes.ts +59 -0
- package/src/index.ts +3 -0
- package/src/lint/audit-catalog.ts +29 -3
- package/src/lint/audit-lineage.ts +14 -2
- package/src/lint/post-synth/fixtures/TF024/live-with-record-store/main.tf +18 -0
- package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/estate.chdf.hcl +1 -0
- package/src/lint/post-synth/fixtures/TF024/sidecar-with-backend/main.tf +10 -0
- package/src/lint/post-synth/fixtures/TF046/azurerm-no-resource-group/main.tf +15 -0
- package/src/lint/post-synth/fixtures/TF046/backend-config-only/main.tf +14 -0
- package/src/lint/post-synth/fixtures/TF046/derived-s3/backend.tf +7 -0
- package/src/lint/post-synth/fixtures/TF046/derived-s3/main.tf +9 -0
- package/src/lint/post-synth/fixtures/TF046/explicit-local/main.tf +16 -0
- package/src/lint/post-synth/fixtures/TF046/explicit-s3-beside-local-backend/main.tf +15 -0
- package/src/lint/post-synth/fixtures/TF046/implied-local/main.tf +9 -0
- package/src/lint/post-synth/fixtures/TF046/sidecar-implied/estate.chdf.hcl +1 -0
- package/src/lint/post-synth/fixtures/TF046/sidecar-implied/main.tf +5 -0
- package/src/lint/post-synth/fixtures/TF047/clear/main.tf +12 -0
- package/src/lint/post-synth/fixtures/TF047/refused/main.tf +12 -0
- package/src/lint/post-synth/fixtures/TF047/unknown-module/main.tf +12 -0
- package/src/lint/post-synth/fixtures/TF047/unknown-version/main.tf +12 -0
- package/src/lint/post-synth/index.ts +4 -0
- package/src/lint/post-synth/record-store.ts +122 -0
- package/src/lint/post-synth/tf001.ts +2 -2
- package/src/lint/post-synth/tf024.test.ts +26 -5
- package/src/lint/post-synth/tf024.ts +105 -22
- package/src/lint/post-synth/tf046.test.ts +137 -0
- package/src/lint/post-synth/tf046.ts +204 -0
- package/src/lint/post-synth/tf047.test.ts +56 -0
- package/src/lint/post-synth/tf047.ts +114 -0
- package/src/lock-rows.test.ts +70 -0
- package/src/lock-rows.ts +82 -0
- package/src/lock-timeout.ts +34 -0
- package/src/module-catalog/index.test.ts +93 -0
- package/src/module-catalog/index.ts +159 -0
- package/src/module-catalog/refresh-cli.ts +68 -0
- package/src/module-catalog/static-tier.ts +1659 -0
- package/src/module-catalog/types.ts +88 -0
- package/src/op/activities/terraform.ts +46 -5
- package/src/op-wave-step.test.ts +109 -0
- package/src/pin/__fixtures__/consumers/live/dev/main.tf +4 -0
- package/src/pin/__fixtures__/consumers/live/prod/main.tf +21 -0
- package/src/pin/__fixtures__/consumers/units/vpc/terragrunt.hcl +7 -0
- package/src/pin/consumers.test.ts +57 -0
- package/src/pin/consumers.ts +95 -0
- package/src/plugin.ts +6 -0
- package/src/registry/__fixtures__/docs/documented/.terraform-docs.yml +3 -0
- package/src/registry/__fixtures__/docs/documented/README.md +1 -0
- package/src/registry/__fixtures__/docs/documented/main.tf +8 -0
- package/src/registry/__fixtures__/docs/json/main.tf.json +14 -0
- package/src/registry/__fixtures__/docs/vpc/README.md +3 -0
- package/src/registry/__fixtures__/docs/vpc/examples/complete/main.tf +5 -0
- package/src/registry/__fixtures__/docs/vpc/examples/simple/README.md +1 -0
- package/src/registry/__fixtures__/docs/vpc/examples/simple/main.tf +4 -0
- package/src/registry/__fixtures__/docs/vpc/main.tf +14 -0
- package/src/registry/__fixtures__/docs/vpc/outputs.tf +9 -0
- package/src/registry/__fixtures__/docs/vpc/variables.tf +16 -0
- package/src/registry/__fixtures__/proxied-root/main.tf +12 -0
- package/src/registry/address.ts +100 -0
- package/src/registry/catalog-read.ts +56 -0
- package/src/registry/deprecated.test.ts +139 -0
- package/src/registry/deprecated.ts +76 -0
- package/src/registry/docs.test.ts +140 -0
- package/src/registry/docs.ts +299 -0
- package/src/registry/edge/bundle.test.ts +50 -0
- package/src/registry/edge/edge.test.ts +176 -0
- package/src/registry/edge/edge.ts +211 -0
- package/src/registry/edge/index.ts +10 -0
- package/src/registry/edge/lambda-edge.ts +127 -0
- package/src/registry/edge/sigv4-web.ts +79 -0
- package/src/registry/edge/token-source.test.ts +258 -0
- package/src/registry/edge/token-source.ts +169 -0
- package/src/registry/edge/worker.ts +61 -0
- package/src/registry/handler.ts +89 -0
- package/src/registry/headers-file.ts +61 -0
- package/src/registry/index.ts +31 -0
- package/src/registry/mirror-paths.ts +10 -0
- package/src/registry/mirror.test.ts +198 -0
- package/src/registry/mirror.ts +395 -0
- package/src/registry/proxies.test.ts +153 -0
- package/src/registry/proxies.ts +132 -0
- package/src/registry/reader.ts +225 -0
- package/src/registry/registry.test.ts +262 -0
- package/src/registry/semver.ts +34 -0
- package/src/registry/serve.ts +82 -0
- package/src/registry/source-forms.test.ts +87 -0
- package/src/registry/source-forms.ts +216 -0
- package/src/registry/targets/artifactory.test.ts +248 -0
- package/src/registry/targets/artifactory.ts +257 -0
- package/src/registry/targets/fake-artifactory.ts +158 -0
- package/src/registry/targets/fake-gitlab.ts +161 -0
- package/src/registry/targets/fake-hcp.ts +233 -0
- package/src/registry/targets/fake-http.ts +97 -0
- package/src/registry/targets/fake-nexus.ts +152 -0
- package/src/registry/targets/gitlab.test.ts +208 -0
- package/src/registry/targets/gitlab.ts +223 -0
- package/src/registry/targets/hcp.test.ts +230 -0
- package/src/registry/targets/hcp.ts +360 -0
- package/src/registry/targets/hosted.ts +117 -0
- package/src/registry/targets/index.ts +17 -0
- package/src/registry/targets/module-target.ts +131 -0
- package/src/registry/targets/nexus.test.ts +220 -0
- package/src/registry/targets/nexus.ts +314 -0
- package/src/registry/targets/zip.test.ts +65 -0
- package/src/registry/targets/zip.ts +287 -0
- package/src/registry/writer.ts +155 -0
- package/src/state/azure-blob.ts +6 -221
- package/src/state/gcs.ts +5 -252
- package/src/state/object-store.ts +4 -32
- package/src/state/s3.ts +10 -182
- package/src/state/store.ts +2 -2
- package/src/state-ops.test.ts +182 -0
- package/src/state-ops.ts +462 -0
- package/src/state-reads.ts +116 -0
- package/src/used-sources.test.ts +75 -0
- package/src/used-sources.ts +204 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_version = ">= 1.5.0"
|
|
3
|
+
|
|
4
|
+
live {
|
|
5
|
+
estate = "fixture-estate"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
backend "azurerm" {
|
|
9
|
+
storage_account_name = "fixturestate"
|
|
10
|
+
container_name = "tfstate"
|
|
11
|
+
key = "fixture.terraform.tfstate"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
resource "null_resource" "first" {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_version = ">= 1.5.0"
|
|
3
|
+
|
|
4
|
+
live {
|
|
5
|
+
estate = "fixture-estate"
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
# bucket and region come from -backend-config, which choudoufu does not read.
|
|
9
|
+
backend "s3" {
|
|
10
|
+
key = "fixture/terraform.tfstate"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
resource "null_resource" "first" {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
estate = "fixture-estate"
|
|
@@ -44,6 +44,8 @@ import { tf042 } from "./tf042";
|
|
|
44
44
|
import { tf043 } from "./tf043";
|
|
45
45
|
import { tf044 } from "./tf044";
|
|
46
46
|
import { tf045 } from "./tf045";
|
|
47
|
+
import { tf046 } from "./tf046";
|
|
48
|
+
import { tf047 } from "./tf047";
|
|
47
49
|
|
|
48
50
|
export const postSynthChecks: PostSynthCheck[] = [
|
|
49
51
|
tf001,
|
|
@@ -90,4 +92,6 @@ export const postSynthChecks: PostSynthCheck[] = [
|
|
|
90
92
|
tf043,
|
|
91
93
|
tf044,
|
|
92
94
|
tf045,
|
|
95
|
+
tf046,
|
|
96
|
+
tf047,
|
|
93
97
|
];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The record store a live root resolves to, read from its HCL the way
|
|
3
|
+
* choudoufu resolves it (INTENTIUS/choudoufu#2293, `internal/configs/live_derive.go`
|
|
4
|
+
* at choudoufu 74ffde956bfd97f44b8ad444424584e23321adc2). Shared by TF024,
|
|
5
|
+
* which names where records go, and TF046, which guards a CI root that ends
|
|
6
|
+
* up on the local store, so the two never disagree.
|
|
7
|
+
*
|
|
8
|
+
* The order is choudoufu's:
|
|
9
|
+
*
|
|
10
|
+
* 1. A `record_store "<kind>"` block in the `live` block or the
|
|
11
|
+
* `estate.chdf.hcl` sidecar always wins (`source: "record_store"`).
|
|
12
|
+
* 2. Otherwise the backend block choudoufu ignores under live gives the store,
|
|
13
|
+
* s3 to s3, gcs to gcs, azurerm to azurerm (`source: "backend"`). s3 and gcs
|
|
14
|
+
* need a literal `bucket`; azurerm needs literal `storage_account_name`,
|
|
15
|
+
* `container_name` and `resource_group_name`. A value passed only with
|
|
16
|
+
* `-backend-config` is not in the configuration, so choudoufu does not see
|
|
17
|
+
* it either.
|
|
18
|
+
* 3. Otherwise the store is local (`source: "implied"`), with `note` saying
|
|
19
|
+
* why a backend that was there was not used.
|
|
20
|
+
*
|
|
21
|
+
* This mirrors `record_store.source` and `record_store.note` in
|
|
22
|
+
* `choudoufu live-check -json`. A literal here is a string hcl2json hands back
|
|
23
|
+
* with no `${...}` in it, the same "not determined" reading the Terragrunt
|
|
24
|
+
* rules use (`./terragrunt.ts`).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { BlockBody } from "../../hcl/parse";
|
|
28
|
+
import { backendTypes } from "./tf001";
|
|
29
|
+
import { isExpression } from "./terragrunt";
|
|
30
|
+
|
|
31
|
+
export type RecordStoreSource = "record_store" | "backend" | "implied";
|
|
32
|
+
|
|
33
|
+
export interface ResolvedRecordStore {
|
|
34
|
+
/** `local`, `s3`, `gcs`, `azurerm` or `kubernetes`, or whatever label a `record_store` block carries. */
|
|
35
|
+
kind: string;
|
|
36
|
+
source: RecordStoreSource;
|
|
37
|
+
/** The backend type the store came from, or was not derived from, when there is a backend block. */
|
|
38
|
+
backend?: string;
|
|
39
|
+
/** Why a backend block that was present did not give a store. Set only with `source: "implied"`. */
|
|
40
|
+
note?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Backend types choudoufu derives a record store from (INTENTIUS/choudoufu#2293). */
|
|
44
|
+
export const DERIVABLE_BACKENDS: ReadonlySet<string> = new Set(["s3", "gcs", "azurerm"]);
|
|
45
|
+
|
|
46
|
+
const asRecord = (v: unknown): BlockBody =>
|
|
47
|
+
typeof v === "object" && v !== null && !Array.isArray(v) ? (v as BlockBody) : {};
|
|
48
|
+
|
|
49
|
+
const firstBody = (v: unknown): BlockBody => asRecord(Array.isArray(v) ? v[0] : v);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The label of a `record_store "<kind>"` block in a live declaration body, or
|
|
53
|
+
* undefined when it declares none. hcl2json nests the label one level down,
|
|
54
|
+
* as it does for `backend` (see `backendTypes` in `./tf001.ts`).
|
|
55
|
+
*/
|
|
56
|
+
export function recordStoreKind(liveBody: BlockBody): string | undefined {
|
|
57
|
+
const raw = liveBody["record_store"];
|
|
58
|
+
if (raw === undefined || raw === null) return undefined;
|
|
59
|
+
if (typeof raw !== "object" || Array.isArray(raw)) return undefined;
|
|
60
|
+
const labels = Object.keys(raw as BlockBody);
|
|
61
|
+
return labels[0];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** A top-level backend argument as a literal string, or undefined when it is absent, empty or an expression. */
|
|
65
|
+
function literal(body: BlockBody, name: string): string | undefined {
|
|
66
|
+
const v = body[name];
|
|
67
|
+
if (typeof v !== "string" || v === "" || isExpression(v)) return undefined;
|
|
68
|
+
return v;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Why a backend block gives no record store, or undefined when it gives one.
|
|
73
|
+
* The wording follows choudoufu's `Live.RecordStoreNote`; an empty string
|
|
74
|
+
* means no store and nothing to say (a `local` backend).
|
|
75
|
+
*/
|
|
76
|
+
function derivationNote(type: string, body: BlockBody): string | undefined {
|
|
77
|
+
const where = `backend "${type}"`;
|
|
78
|
+
switch (type) {
|
|
79
|
+
case "s3":
|
|
80
|
+
case "gcs":
|
|
81
|
+
return literal(body, "bucket") === undefined
|
|
82
|
+
? `${where} sets no literal bucket; values passed with -backend-config are not read`
|
|
83
|
+
: undefined;
|
|
84
|
+
case "azurerm":
|
|
85
|
+
for (const name of ["storage_account_name", "container_name", "resource_group_name"]) {
|
|
86
|
+
if (literal(body, name) === undefined) return `${where} sets no literal ${name}, which the azurerm record store needs`;
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
case "local":
|
|
90
|
+
// choudoufu leaves no note here: a local backend and the local store agree.
|
|
91
|
+
return "";
|
|
92
|
+
default:
|
|
93
|
+
return `${where} has no record store counterpart`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Resolve one live root's record store.
|
|
99
|
+
*
|
|
100
|
+
* `terraformBodies` are the bodies of every `terraform` block in the root (a
|
|
101
|
+
* backend can sit in a separate `backend.tf`). `liveBodies` are the root's
|
|
102
|
+
* live declarations: its `live` block and its sidecar, if any. choudoufu
|
|
103
|
+
* refuses a root that has both, so the first `record_store` found is the one.
|
|
104
|
+
*/
|
|
105
|
+
export function resolveRecordStore(
|
|
106
|
+
terraformBodies: readonly BlockBody[],
|
|
107
|
+
liveBodies: readonly BlockBody[],
|
|
108
|
+
): ResolvedRecordStore {
|
|
109
|
+
for (const live of liveBodies) {
|
|
110
|
+
const kind = recordStoreKind(live);
|
|
111
|
+
if (kind !== undefined) return { kind, source: "record_store" };
|
|
112
|
+
}
|
|
113
|
+
for (const tf of terraformBodies) {
|
|
114
|
+
const type = backendTypes(tf)[0];
|
|
115
|
+
if (type === undefined) continue;
|
|
116
|
+
const body = firstBody(asRecord(tf["backend"])[type]);
|
|
117
|
+
const note = derivationNote(type, body);
|
|
118
|
+
if (note === undefined) return { kind: type, source: "backend", backend: type };
|
|
119
|
+
return { kind: "local", source: "implied", backend: type, ...(note ? { note } : {}) };
|
|
120
|
+
}
|
|
121
|
+
return { kind: "local", source: "implied" };
|
|
122
|
+
}
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
* module's `terraform` block is skipped here rather than read as if it were
|
|
31
31
|
* the root's.
|
|
32
32
|
*
|
|
33
|
-
* Does not fire on a live root (#2103): a `backend` block
|
|
34
|
-
*
|
|
33
|
+
* Does not fire on a live root (#2103): choudoufu ignores a `backend` block
|
|
34
|
+
* there (TF024 reports what it still does with it), and the fallback to local
|
|
35
35
|
* state this check warns about does not apply, since a live root keeps no
|
|
36
36
|
* state file at all, local or remote.
|
|
37
37
|
*/
|
|
@@ -13,18 +13,39 @@ async function ctxFor(fixture: string, root = "estate"): Promise<PostSynthContex
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
describe("TF024: live root declares a backend or cloud block", () => {
|
|
16
|
-
test("
|
|
16
|
+
test("reports a backend block as ignored, at info, with the store derived from it", async () => {
|
|
17
17
|
const diags = tf024.check(await ctxFor("live-with-backend"));
|
|
18
18
|
expect(diags).toHaveLength(1);
|
|
19
19
|
expect(diags[0].checkId).toBe("TF024");
|
|
20
|
-
expect(diags[0].
|
|
21
|
-
expect(diags[0].message).toContain(
|
|
20
|
+
expect(diags[0].severity).toBe("info");
|
|
21
|
+
expect(diags[0].message).toContain('backend "s3"');
|
|
22
|
+
expect(diags[0].message).toContain("ignores it");
|
|
23
|
+
expect(diags[0].message).toContain("-migrate-state");
|
|
24
|
+
expect(diags[0].message).toContain("derives the record store");
|
|
25
|
+
expect(diags[0].message).not.toContain("refuses this at init");
|
|
22
26
|
});
|
|
23
27
|
|
|
24
|
-
test("
|
|
28
|
+
test("says an explicit record_store wins over the backend", async () => {
|
|
29
|
+
const diags = tf024.check(await ctxFor("live-with-record-store"));
|
|
30
|
+
expect(diags).toHaveLength(1);
|
|
31
|
+
expect(diags[0].severity).toBe("info");
|
|
32
|
+
expect(diags[0].message).toContain("record_store the live declaration names");
|
|
33
|
+
expect(diags[0].message).not.toContain("derives the record store");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("keys on an estate.chdf.hcl sidecar as well as a live block", async () => {
|
|
37
|
+
const diags = tf024.check(await ctxFor("sidecar-with-backend"));
|
|
38
|
+
expect(diags).toHaveLength(1);
|
|
39
|
+
expect(diags[0].message).toContain('backend "gcs"');
|
|
40
|
+
expect(diags[0].message).toContain("derives the record store");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("warns on a cloud block, which choudoufu drops entirely", async () => {
|
|
25
44
|
const diags = tf024.check(await ctxFor("live-with-cloud"));
|
|
26
45
|
expect(diags).toHaveLength(1);
|
|
27
|
-
expect(diags[0].
|
|
46
|
+
expect(diags[0].severity).toBe("warning");
|
|
47
|
+
expect(diags[0].message).toContain("cloud block");
|
|
48
|
+
expect(diags[0].message).toContain("no record store is derived");
|
|
28
49
|
});
|
|
29
50
|
|
|
30
51
|
test("passes a live root with neither block", async () => {
|
|
@@ -1,18 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TF024: a live root declares a `backend` or `cloud` block.
|
|
3
3
|
*
|
|
4
|
-
* choudoufu
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* choudoufu used to refuse this pair at `init` (#1170). Since
|
|
5
|
+
* INTENTIUS/choudoufu#2213 it accepts both and ignores them with a warning
|
|
6
|
+
* (`internal/configs/module.go`, `ignoreStateStoreUnderLive`), because
|
|
7
|
+
* Terragrunt's `remote_state` and Atmos's `backend.tf.json` write a backend
|
|
8
|
+
* beside the live block on every run. What each block still does:
|
|
9
|
+
*
|
|
10
|
+
* - `backend "<type>"`: no state is read or written there, and
|
|
11
|
+
* `init -migrate-state` is refused. choudoufu keeps the block as
|
|
12
|
+
* `IgnoredBackend`: an apply publishes the estate's non-sensitive outputs
|
|
13
|
+
* to the location it names, so `terraform_remote_state` readers keep
|
|
14
|
+
* working, and when the live declaration has no `record_store` the record
|
|
15
|
+
* store is derived from the backend's bucket, s3 to s3, gcs to gcs, azurerm
|
|
16
|
+
* to azurerm (INTENTIUS/choudoufu#2293), when the bucket is a literal in
|
|
17
|
+
* the configuration. An explicit `record_store` always wins. The resolution
|
|
18
|
+
* is shared with TF046 in `./record-store.ts`.
|
|
19
|
+
* - `cloud {}`: dropped entirely. Nothing is published to it and no store is
|
|
20
|
+
* derived from it.
|
|
21
|
+
*
|
|
22
|
+
* So the backend case is reported as `info` (the block is doing a job the
|
|
23
|
+
* author may want, and is the derivation source the maintainer ruled for),
|
|
24
|
+
* and the cloud case as `warning` (the block does nothing at all). Neither
|
|
25
|
+
* fails a build at default severity. The guard against a CI root that ends
|
|
26
|
+
* up on the local store is TF046 (chant#4561).
|
|
27
|
+
*
|
|
28
|
+
* The live marker is the root's `mode`, stamped from either a `live` block or
|
|
29
|
+
* an `estate.chdf.hcl` sidecar (`hcl/parse.ts`), so a sidecar estate is
|
|
30
|
+
* covered. A `record_store` is read from whichever `Terraform::Live` entity
|
|
31
|
+
* carries it: the `live` block, or the sidecar's top level.
|
|
11
32
|
*
|
|
12
33
|
* TF001 is the equivalent check for a stock root (no remote backend is
|
|
13
|
-
* configured); it
|
|
14
|
-
*
|
|
15
|
-
* at most one of them.
|
|
34
|
+
* configured); it does not fire on a live root. A root is flagged by at most
|
|
35
|
+
* one of them.
|
|
16
36
|
*
|
|
17
37
|
* Scope: root modules only (#2112). A child module's backend or cloud block
|
|
18
38
|
* is TF015's finding, whatever binary the root runs.
|
|
@@ -26,17 +46,74 @@ import type {
|
|
|
26
46
|
PostSynthDiagnostic,
|
|
27
47
|
} from "@intentius/chant/lint/post-synth";
|
|
28
48
|
import { isResourceDeclarable } from "@intentius/chant/declarable";
|
|
29
|
-
import { TERRAFORM_TYPE, type BlockBody } from "../../hcl/parse";
|
|
30
|
-
import { hasBlock } from "./tf001";
|
|
49
|
+
import { LIVE_TYPE, TERRAFORM_TYPE, type BlockBody } from "../../hcl/parse";
|
|
50
|
+
import { backendTypes, hasBlock } from "./tf001";
|
|
31
51
|
import { isRootScoped } from "./scope";
|
|
52
|
+
import { DERIVABLE_BACKENDS, resolveRecordStore, type ResolvedRecordStore } from "./record-store";
|
|
53
|
+
|
|
54
|
+
export { DERIVABLE_BACKENDS } from "./record-store";
|
|
55
|
+
|
|
56
|
+
const bodyOf = (props: { body?: unknown }): BlockBody =>
|
|
57
|
+
(typeof props.body === "object" && props.body !== null ? props.body : {}) as BlockBody;
|
|
58
|
+
|
|
59
|
+
/** Each root's live declarations (its `live` block and its sidecar), keyed by root. */
|
|
60
|
+
export function liveBodiesByRoot(ctx: PostSynthContext): Map<string, BlockBody[]> {
|
|
61
|
+
const roots = new Map<string, BlockBody[]>();
|
|
62
|
+
for (const entity of ctx.entities.values()) {
|
|
63
|
+
if (entity.entityType !== LIVE_TYPE) continue;
|
|
64
|
+
if (!isResourceDeclarable(entity) || !isRootScoped(entity)) continue;
|
|
65
|
+
const props = entity.props as { root?: unknown; body?: unknown };
|
|
66
|
+
const root = typeof props.root === "string" ? props.root : "";
|
|
67
|
+
const list = roots.get(root) ?? [];
|
|
68
|
+
list.push(bodyOf(props));
|
|
69
|
+
roots.set(root, list);
|
|
70
|
+
}
|
|
71
|
+
return roots;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function backendMessage(root: string, type: string, store: ResolvedRecordStore): string {
|
|
75
|
+
const label = type ? `backend "${type}"` : "backend";
|
|
76
|
+
const head =
|
|
77
|
+
`Root module "${root}" runs choudoufu with a declared estate and also declares a ${label} block. ` +
|
|
78
|
+
"choudoufu ignores it with a warning: no state is read or written there and `init -migrate-state` " +
|
|
79
|
+
"is refused. An apply publishes the estate's non-sensitive outputs to the location it names, so " +
|
|
80
|
+
"terraform_remote_state readers keep working.";
|
|
81
|
+
if (store.source === "record_store") {
|
|
82
|
+
return `${head} Records go to the record_store the live declaration names, which wins over the backend.`;
|
|
83
|
+
}
|
|
84
|
+
if (store.source === "backend") {
|
|
85
|
+
return (
|
|
86
|
+
`${head} With no record_store declared, choudoufu derives the record store from this backend's ` +
|
|
87
|
+
"bucket and prints it on every init and plan (INTENTIUS/choudoufu#2293). Declare record_store to " +
|
|
88
|
+
"put records somewhere else."
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const why = DERIVABLE_BACKENDS.has(type) && store.note
|
|
92
|
+
? `No record store is derived from it: ${store.note}.`
|
|
93
|
+
: `No record store is derived from a ${type ? `"${type}"` : "backend of unknown type"} (only s3, gcs and azurerm are).`;
|
|
94
|
+
return (
|
|
95
|
+
`${head} ${why} No record_store is declared, so records stay in the local ` +
|
|
96
|
+
"store. Declare record_store if more than one machine runs this root (TF046 guards this in CI)."
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function cloudMessage(root: string): string {
|
|
101
|
+
return (
|
|
102
|
+
`Root module "${root}" runs choudoufu with a declared estate and also declares a cloud block. ` +
|
|
103
|
+
"choudoufu ignores it entirely: no state is read or written there, no outputs are published to it, " +
|
|
104
|
+
"and no record store is derived from it. Remove it, or use a backend block if " +
|
|
105
|
+
"terraform_remote_state readers need this estate's outputs."
|
|
106
|
+
);
|
|
107
|
+
}
|
|
32
108
|
|
|
33
109
|
export const tf024: PostSynthCheck = {
|
|
34
110
|
id: "TF024",
|
|
35
|
-
description: "Live root declares a backend or cloud block, which choudoufu
|
|
111
|
+
description: "Live root declares a backend or cloud block, which choudoufu ignores",
|
|
36
112
|
|
|
37
113
|
check(ctx: PostSynthContext): PostSynthDiagnostic[] {
|
|
38
114
|
const diagnostics: PostSynthDiagnostic[] = [];
|
|
39
115
|
const flagged = new Set<string>();
|
|
116
|
+
let liveBodies: Map<string, BlockBody[]> | undefined;
|
|
40
117
|
|
|
41
118
|
for (const [name, entity] of ctx.entities) {
|
|
42
119
|
if (entity.entityType !== TERRAFORM_TYPE) continue;
|
|
@@ -46,20 +123,26 @@ export const tf024: PostSynthCheck = {
|
|
|
46
123
|
const root = typeof props.root === "string" ? props.root : "";
|
|
47
124
|
if (flagged.has(root)) continue;
|
|
48
125
|
|
|
49
|
-
const body = (
|
|
50
|
-
const hasBackend = hasBlock(body, "backend");
|
|
126
|
+
const body = bodyOf(props);
|
|
51
127
|
const hasCloud = hasBlock(body, "cloud");
|
|
128
|
+
const hasBackend = hasBlock(body, "backend");
|
|
52
129
|
if (!hasBackend && !hasCloud) continue;
|
|
53
|
-
|
|
54
130
|
flagged.add(root);
|
|
55
|
-
|
|
131
|
+
|
|
132
|
+
// A cloud block does nothing at all, so it is the one worth a warning
|
|
133
|
+
// when a (malformed) root somehow carries both.
|
|
134
|
+
if (hasCloud) {
|
|
135
|
+
diagnostics.push({ checkId: "TF024", severity: "warning", message: cloudMessage(root), entity: name, lexicon: "terraform" });
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
liveBodies ??= liveBodiesByRoot(ctx);
|
|
140
|
+
const type = backendTypes(body)[0] ?? "";
|
|
141
|
+
const store = resolveRecordStore([body], liveBodies.get(root) ?? []);
|
|
56
142
|
diagnostics.push({
|
|
57
143
|
checkId: "TF024",
|
|
58
|
-
severity: "
|
|
59
|
-
message:
|
|
60
|
-
`Root module "${root}" runs choudoufu with a declared estate and also declares a ` +
|
|
61
|
-
`${blockKind} block. choudoufu refuses this at init: "Both a ${blockKind} and a live ` +
|
|
62
|
-
`configuration are present." Remove the ${blockKind} block; a live root keeps no state to store.`,
|
|
144
|
+
severity: "info",
|
|
145
|
+
message: backendMessage(root, type, store),
|
|
63
146
|
entity: name,
|
|
64
147
|
lexicon: "terraform",
|
|
65
148
|
});
|