Skip to content

Lock Terraform providers during init - #2144

Open
lucacavallaro wants to merge 5 commits into
mainfrom
terraform-provider-locking
Open

Lock Terraform providers during init#2144
lucacavallaro wants to merge 5 commits into
mainfrom
terraform-provider-locking

Conversation

@lucacavallaro

@lucacavallaro lucacavallaro commented Sep 3, 2026

Copy link
Copy Markdown
Member

Why

Terraform initialization could leave .terraform.lock.hcl with checksums for only the current platform, requiring the pre-commit hook to repair it later. Developer initialization should produce the repository's supported platform locks directly for the selected module.

What changed

  • Run terraform providers lock for Windows AMD64, macOS AMD64/ARM64, and Linux AMD64 in only the selected Terraform module.
  • Generate provider locks only in non-CI mode; CI relies on Terraform's native provider-lock validation.
  • Preserve the existing frozen tfmodules.lock.json validation.
  • Rebuild the Nx Terraform plugin bundle and update its executor documentation.
  • Add coverage for command ordering, provider failures, and skipping provider generation in CI.

Validation

pnpm nx run-many -t build test lint typecheck -p @pagopa/dx-tasks @pagopa/nx-terraform-plugin --skipNxCache

Ensure provider lockfiles contain checksums for every supported platform and frozen initialization detects drift without modifying the checkout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lucacavallaro
lucacavallaro requested a review from a team as a code owner September 3, 2026 14:44
@gunzip
gunzip requested a balanced review from Copilot September 3, 2026 14:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes have no unresolved approval-blocking issues.

Pull request overview

Adds multi-platform Terraform provider locking to initialization with frozen-mode drift detection and restoration.

Changes:

  • Locks providers for four supported platforms.
  • Restores frozen lockfiles on drift or failure.
  • Updates tests, documentation, generated bundles, and release plans.
File summaries
File Description
packages/nx-terraform-plugin/src/executors/init/schema.json Documents provider-lock behavior.
packages/nx-terraform-plugin/README.md Explains normal and frozen initialization.
packages/nx-terraform-plugin/dist/executors/plan/plan.js References the rebuilt dispatcher.
packages/nx-terraform-plugin/dist/executors/init/init.js References the rebuilt dispatcher.
packages/nx-terraform-plugin/dist/default-dispatcher-DhKv9MFb.js Rebuilds the bundled task implementation.
packages/dx-tasks/src/terraform/init.ts Implements provider locking and frozen restoration.
packages/dx-tasks/src/terraform/__tests__/init.test.ts Tests ordering, failures, drift, and restoration.
.nx/version-plans/version-plan-1788444775645.md Plans patch releases for affected packages.
Review details
  • Files reviewed: 5/8 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

lucacavallaro and others added 4 commits September 3, 2026 17:58
Rely on Terraform's native lockfile validation in CI while retaining multi-platform provider lock generation for developer initialization.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep Terraform initialization focused after provider lock validation was delegated back to Terraform in CI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep coverage for format-2 module lock drift while asserting that frozen initialization uses Terraform's read-only provider lock mode.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants