Skip to content

fix(terraform): align provider version floors across modules#1242

Open
cristim wants to merge 2 commits into
mainfrom
fix/inf-08-fix
Open

fix(terraform): align provider version floors across modules#1242
cristim wants to merge 2 commits into
mainfrom
fix/inf-08-fix

Conversation

@cristim

@cristim cristim commented Jun 11, 2026

Copy link
Copy Markdown
Member

Problem

Code-review finding INF-08 (#1188): the azure environment root and all consumed modules pin azurerm ~> 3.0, while three orphaned modules (registry/azure, monitoring/azure, compute/azure/cleanup-function) pinned ~> 4.0. The ranges are mutually exclusive, so terraform init would fail the moment those modules are wired into the root. AWS and GCP floors were also mixed: seven modules used unbounded >= 5.0 against the roots' ~> 5.0, which let their module-local lock files drift to provider majors no consuming root ever applies (aws 6.33.0, google 7.20.0, azurerm 4.70.0).

Fix

  • Pin registry/azure, monitoring/azure, and compute/azure/cleanup-function to azurerm ~> 3.0, matching the azure root and every other azurerm consumer (also drops the stale comment in monitoring/azure referencing a previously-committed 4.61.0 lock that no longer exists).
  • Convert >= 5.0 to ~> 5.0 in registry/{aws,gcp}, monitoring/{aws,gcp}, compute/aws/{fargate,cleanup-lambda}, and compute/gcp/cleanup-function.
  • Pin the environments/aws/ci-cd-permissions bootstrap root to ~> 6.0 instead of >= 5.0: its committed lock is already applied at aws 6.36.0, so aligning it down to ~> 5.0 would force a provider downgrade of live bootstrap state. A comment documents the deliberate divergence from the workload roots.
  • Keep iam/azure/cudly-reservation-role at >= 3.0 with a comment: it is consumed by both an azurerm 3.x root (environments/azure/ci-cd-permissions) and an azurerm 4.x root (iac/federation/azure-target), so its constraint must intersect both provider lines.
  • Regenerate the ten module-local .terraform.lock.hcl files under the aligned constraints. They now select the same versions the consuming roots actually apply (aws 5.100.0, google 5.45.2, azurerm 3.117.1), with multi-platform hashes (linux/darwin, amd64/arm64).
  • Convert registry/azure's two azurerm 4.x-only scalar attributes (trust_policy_enabled, retention_policy_in_days) to the 3.x nested trust_policy/retention_policy blocks, emitted via dynamic only for the Premium SKU. Same effective configuration; the module now validates under azurerm 3.117.1.

Orphaned modules: kept, not deleted

Grep confirms nothing instantiates registry/azure, monitoring/{aws,gcp,azure}, compute/azure/cleanup-function, compute/aws/cleanup-lambda, or compute/gcp/cleanup-function (no module block, workflow, script, or Makefile reference). They are deliberately kept rather than removed:

  • The three cleanup modules are the deployment vehicle for live, actively maintained Go code (cmd/cleanup-lambda; the GCP cleanup-function was hardened in 3c6c9f3).
  • Wiring them into the environment roots (vs deleting) is a deployment decision for the maintainer; this PR removes the latent init conflict so wiring becomes possible without further version work.
  • The pre-commit terraform_validate exclusion for registry/azure and compute/azure/cleanup-function is tracked separately per its own comment and is untouched here; both directories now validate clean locally, so that exclusion can likely be dropped in its own cleanup.

Test evidence

terraform init -backend=false && terraform validate run in all 15 affected directories (10 modules + environments/{aws,gcp,azure} + aws and azure ci-cd-permissions roots): all validate clean. The azure 4.x-to-3.x downgrades were schema-checked against the real azurerm 3.117.1 provider via validate. No churn in any environment root lock file.

Closes #1188

@cristim cristim added triaged Item has been triaged priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/m Days type/chore Maintenance / non-user-visible labels Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 12 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f2aa8846-6ba8-4d4c-89f7-d65e434b9a17

📥 Commits

Reviewing files that changed from the base of the PR and between 1d9f1b8 and fd3f10c.

📒 Files selected for processing (25)
  • .pre-commit-config.yaml
  • terraform/environments/aws/ci-cd-permissions/.terraform.lock.hcl
  • terraform/environments/aws/ci-cd-permissions/main.tf
  • terraform/modules/compute/aws/cleanup-lambda/.terraform.lock.hcl
  • terraform/modules/compute/aws/cleanup-lambda/versions.tf
  • terraform/modules/compute/aws/fargate/.terraform.lock.hcl
  • terraform/modules/compute/aws/fargate/versions.tf
  • terraform/modules/compute/azure/cleanup-function/.terraform.lock.hcl
  • terraform/modules/compute/azure/cleanup-function/versions.tf
  • terraform/modules/compute/gcp/cleanup-function/.terraform.lock.hcl
  • terraform/modules/compute/gcp/cleanup-function/versions.tf
  • terraform/modules/iam/azure/cudly-reservation-role/main.tf
  • terraform/modules/monitoring/aws/.terraform.lock.hcl
  • terraform/modules/monitoring/aws/versions.tf
  • terraform/modules/monitoring/azure/.terraform.lock.hcl
  • terraform/modules/monitoring/azure/versions.tf
  • terraform/modules/monitoring/gcp/.terraform.lock.hcl
  • terraform/modules/monitoring/gcp/versions.tf
  • terraform/modules/registry/aws/.terraform.lock.hcl
  • terraform/modules/registry/aws/versions.tf
  • terraform/modules/registry/azure/.terraform.lock.hcl
  • terraform/modules/registry/azure/main.tf
  • terraform/modules/registry/azure/versions.tf
  • terraform/modules/registry/gcp/.terraform.lock.hcl
  • terraform/modules/registry/gcp/versions.tf
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/inf-08-fix

Comment @coderabbitai help to get the list of available commands.

@cristim

cristim commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

Adversarial review

Verified the version-floor logic across every required_providers block in terraform/modules/** and terraform/environments/**. Floors are now uniformly aws ~> 5.0, azurerm ~> 3.0, google ~> 5.0 with the two documented exceptions: environments/aws/ci-cd-permissions pinned at aws ~> 6.0 to match the live 6.36.0 bootstrap lock, and modules/iam/azure/cudly-reservation-role left at azurerm >= 3.0 to intersect both the 3.x host-side and the 4.x iac/federation/azure-target consumer. The cross-major split is real: cudly_reservation_role is invoked from both terraform/environments/azure/ci-cd-permissions/reservation_role.tf (azurerm ~> 3.0) and iac/federation/azure-target/terraform/main.tf (azurerm ~> 4.0), and the only resource it owns is azurerm_role_definition, whose schema is identical between 3.x and 4.x — safe.

The 10 regenerated module lock files all pin to the versions the consuming roots apply (aws 5.100.0, google 5.45.2, azurerm 3.117.1) with multi-platform hashes. The terraform/environments/{aws,gcp,azure}/.terraform.lock.hcl root locks are untouched (no churn for live state), as the PR description claims.

UNSTABLE not from this PR

The Lint Code, Integration Tests, Security Scanning, and CI Success failures all exist on main ahead of this PR — verified by checking the latest main CI run for SHA 451a70f (same four failures, identical errcheck/sched-auth-key-rotation/etc.). The three Terraform-relevant jobs (Validate Terraform (aws|gcp|azure)) all pass. Not blocking on this PR.

In-scope fixes pushed to fix/inf-08-fix (f5f5524)

  1. Stale lock constraint metadata in terraform/environments/aws/ci-cd-permissions/.terraform.lock.hcl. Source was changed to ~> 6.0 but the lock's constraints metadata still read >= 5.0.0. Self-heals on next terraform init, but committing it inconsistent leaves the file stale relative to its source. Updated the constraints line to ~> 6.0.
  2. Now-stale terraform_validate exclusion in .pre-commit-config.yaml. The exclusion comment cited "dynamic blocks around scalar attributes — invalid HCL in any azurerm version" for modules/compute/azure/cleanup-function/ and modules/registry/azure/. This PR specifically removed that pattern (registry/azure converted to proper 3.x nested blocks emitted via dynamic; cleanup-function dropped the dynamic-around-scalar wrapper). Verified locally both now pass terraform init -backend=false && terraform validate under the pinned azurerm 3.117.1, and pre-commit run terraform_validate --all-files succeeds without exclusions. Dropped the exclusion + stale comment so future regressions are caught by pre-commit.

Out-of-scope follow-up filed: #1291

Same INF-08 unbounded->=-floor pattern is still present in the per-customer onboarding bundles under iac/federation/** (aws-cross-account, aws-target, gcp-target, gcp-sa-impersonation all pin >= 5.0). Different risk shape — those are customer-side, no internal lock churn — but a customer onboarding today resolves to a different provider major than one onboarding 12 months ago, with no version policy on our side. azure-target's ~> 4.0 is intentional and stays. Tracked as a separate chore.

@cristim

cristim commented Jun 26, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@cristim

cristim commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Rebased onto origin/main (27fdb06). Clean 2-commit rebase, no conflicts. Gates: go build/vet exit 0.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@cristim: I’ll review the rebased changes and their updated base context.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Rebased onto origin/main (89658a3 -> a945344) which includes #1437 (tflint plugin cache + retry) and #1438 (trivy \*\*/.terraform skip). Workflow files confirmed to match main. .pre-commit-config.yaml diff vs main is intentional (PR removes the terraform_validate exclusion block) while retaining both trivy skip-dirs fixes. No Go/frontend files touched. Pre-commit should be fully green.

The azure root and all consumed modules pin azurerm ~> 3.0, but three
orphaned modules (registry/azure, monitoring/azure,
compute/azure/cleanup-function) pinned ~> 4.0, a mutually exclusive
range that would break terraform init the moment they are wired into
the environment root. AWS and GCP module floors were also mixed:
unbounded >= 5.0 in seven modules vs ~> 5.0 in the environment roots,
which let module-local lock files drift to provider majors (aws 6.33.0,
google 7.20.0, azurerm 4.70.0) that no consuming root ever applies.

Changes:
- Pin the three azure 4.x modules to ~> 3.0, matching the azure
  environment root and every other azurerm consumer.
- Convert >= 5.0 to ~> 5.0 in registry/{aws,gcp}, monitoring/{aws,gcp},
  compute/aws/{fargate,cleanup-lambda} and compute/gcp/cleanup-function.
- Pin the aws ci-cd-permissions bootstrap root to ~> 6.0 (its committed
  lock file is already applied at 6.36.0; pinning to 5.x would force a
  provider downgrade of live bootstrap state).
- Keep iam/azure/cudly-reservation-role at >= 3.0 with a comment: it is
  consumed by both an azurerm 3.x root (environments/azure/
  ci-cd-permissions) and an azurerm 4.x root (iac/federation/
  azure-target), so its constraint must intersect both lines.
- Regenerate the ten module-local lock files under the aligned
  constraints; they now select the same provider versions the consuming
  environment roots actually apply (aws 5.100.0, google 5.45.2,
  azurerm 3.117.1) with multi-platform hashes.
- Convert registry/azure's two azurerm 4.x-only scalar attributes
  (trust_policy_enabled, retention_policy_in_days) to the 3.x nested
  trust_policy/retention_policy blocks, emitted only for the Premium
  SKU; same effective configuration, now valid under azurerm 3.x.

The orphaned modules themselves (registry/azure, monitoring/{aws,gcp,
azure}, the three cleanup modules) are kept: they implement the
staging-TTL cleanup and monitoring stacks with live Go code in
cmd/cleanup-lambda, and wiring them into the environment roots is a
deployment decision tracked separately.

Verified with terraform init -backend=false && terraform validate in
all ten modules and the five roots (aws/gcp/azure environments plus
aws and azure ci-cd-permissions); all pass with no root lock churn.

Closes #1188
…le validate exclusion

Two follow-ups from the adversarial review on the INF-08 version-floor PR:

- The bootstrap root constraint in `terraform/environments/aws/ci-cd-permissions/main.tf` was changed from `>= 5.0` to `~> 6.0` to match the live 6.36.0 lock, but the lock file's own `constraints` metadata still recorded `>= 5.0.0` (it self-heals on the next `terraform init`, but committing it stale leaves the file inconsistent with its source). Update the constraints line in `.terraform.lock.hcl` to `~> 6.0` so the metadata matches the source pin without waiting for a deploy to rewrite it.

- The `.pre-commit-config.yaml` `terraform_validate` exclusion for `terraform/modules/compute/azure/cleanup-function/` and `terraform/modules/registry/azure/` was justified by a comment about `dynamic` blocks around scalar attributes being invalid HCL. The original PR specifically converted those scalar attributes back to azurerm 3.x nested `trust_policy`/`retention_policy` blocks emitted via `dynamic` (for registry/azure) and dropped the dynamic-around-scalar wrapper in cleanup-function. Both directories now validate clean under the pinned azurerm 3.117.1: confirmed by running `terraform init -backend=false && terraform validate` locally, and by `pre-commit run terraform_validate --all-files` passing without exclusions. Drop the exclusion (and the now-stale comment) so future regressions are caught by pre-commit instead of slipping through.

No source-code or lockfile-version changes; provider versions stay at aws 6.36.0 and azurerm 3.117.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/chore Maintenance / non-user-visible urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

INF-08: azurerm provider constraint split (~>3.0 root vs ~>4.0 modules) plus orphaned modules nothing instantiates

1 participant