Support releasable Terraform environments#1995
Conversation
Teach the Terraform Nx plugin to discover environment manifests, infer release targets, and version application projects without activating any concrete deployment environment. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Code Review ReportTerraform Plan:
|
There was a problem hiding this comment.
Pull request overview
This PR extends the @pagopa/nx-terraform-plugin to support releasable Terraform environment projects by introducing an environment.json manifest contract, enabling Nx Release to identify and version environment projects similarly to existing module.json-backed Terraform modules.
Changes:
- Added discovery + validation for
environment.jsonmanifests and surfaced them in node creation. - Inferred environment release targets (
tf-plan-upload,nx-release-publish) and enabled Nx Release disk-based versioning for manifest-backed environment applications. - Updated Terraform
VersionActionsto read/write versions frommodule.json(libraries) orenvironment.json(applications), with added unit tests and rebuilt dist artifacts.
Reviewed changes
Copilot reviewed 12 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Records the new dependency resolution for nx added to the plugin. |
| packages/nx-terraform-plugin/src/release/version-actions.ts | Selects manifest filename by projectType to support both modules and environments in Nx Release versioning. |
| packages/nx-terraform-plugin/src/release/tests/version-actions.test.ts | Adds coverage for application (environment.json) version read/update behavior. |
| packages/nx-terraform-plugin/src/project.ts | Infers release targets and Nx Release config for environment.json-backed application projects. |
| packages/nx-terraform-plugin/src/manifest.ts | Introduces environment.json schema + parser and related error type. |
| packages/nx-terraform-plugin/src/index.ts | Discovers environment.json files and wires validated manifests into project generation. |
| packages/nx-terraform-plugin/src/discovery.ts | Adds readEnvironmentManifest to load/validate environment manifests from disk. |
| packages/nx-terraform-plugin/src/tests/project.test.ts | Validates inferred targets and release config for environment applications. |
| packages/nx-terraform-plugin/src/tests/index.test.ts | Updates discovery glob expectation to include environment.json. |
| packages/nx-terraform-plugin/src/tests/environment-manifest.test.ts | Adds unit tests for environment manifest parsing/validation. |
| packages/nx-terraform-plugin/src/tests/environment-discovery.test.ts | Adds tests for reading environment manifests from disk and handling invalid cases. |
| packages/nx-terraform-plugin/package.json | Adds runtime dependency on nx for nx/release usage. |
| packages/nx-terraform-plugin/dist/release/version-actions.js | Rebuilt compiled artifact reflecting the updated version actions logic. |
| packages/nx-terraform-plugin/dist/index.js | Rebuilt compiled artifact reflecting manifest discovery + environment support. |
| .nx/version-plans/version-plan-1784226868463.md | Adds a version plan for the plugin release due to user-facing behavior changes. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
Why
Terraform environment projects need an explicit manifest contract before release orchestration can identify, version, and deploy them safely.
What changed
environment.jsonmanifests in the Terraform Nx plugin.tf-plan-uploadandnx-release-publishtargets for manifest-backed application projects.No repository environment manifest is added in this PR, so existing project graphs and deployment behavior remain unchanged.
Validation
pnpm nx run-many -t test lint typecheck -p @pagopa/nx-terraform-pluginpnpm nx run @pagopa/nx-terraform-plugin:buildDepends on #1994.
Extracted from #1926.