Skip to content

feat: script-ify Terraform validation preflight sequence (azure-validate) - #2862

Merged
Tom Meschter (tmeschter) merged 2 commits into
microsoft:mainfrom
tmeschter:tmeschter-glowing-engine
Jul 17, 2026
Merged

feat: script-ify Terraform validation preflight sequence (azure-validate)#2862
Tom Meschter (tmeschter) merged 2 commits into
microsoft:mainfrom
tmeschter:tmeschter-glowing-engine

Conversation

@tmeschter

@tmeschter Tom Meschter (tmeschter) commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #2501.

Replaces the manual, per-command Terraform validation preflight sequence in the azure-validate skill with a pair of run-and-report scripts, per the issue's recommendation.

Changes

  • New scripts at plugin/skills/azure-validate/references/recipes/terraform/scripts/:
    • validate-terraform.sh (bash) and validate-terraform.ps1 (PowerShell), with feature parity.
    • Input: infra directory path (default ./infra), optional subscription id.
    • Runs the full deterministic sequence in one call — terraform installed → az installed → authenticated → initfmt -checkvalidateplanstate list → Go-style {{ .Env.* }} template-variable scan.
    • Runs every step even if an earlier one fails, captures per-step PASS/FAIL/SKIP plus the error text for failed steps, prints a compact summary + FAILURE DETAILS section, and exits non-zero on any failure.
  • recipes/terraform/README.md now references the scripts via markdown links with Usage/Examples and an output-reading guide. Remediation prose (fmt fix, {{ .Env.* }}${VAR}, TF_VAR_*, variables.tf) and the Azure Policy Validation reference stay in prose — only the run-and-report is scripted.

Why

  • Fewer tokens / round-trips — one script call replaces 8+ command generations and large-output parsing.
  • Deterministic & reliable — the logic is written once instead of re-derived each run.
  • Compact, actionable output — the agent jumps straight to remediation for any failed step.

Validation

  • Both scripts parse & run under Windows PowerShell 5.1 and bash (smoke-tested).
  • npm run build stamps versions (azure-validate → 1.1.2).
  • Frontmatter passes against built output; npm run references passes (scripts linked, not orphaned, no escaped links); npm run tokens check passes.
  • azure-validate trigger tests pass. Integration tests run in CI.

Replace the manual, per-command Terraform preflight run mechanics in the azure-validate skill with a pair of run-and-report scripts (validate-terraform.sh / .ps1) that execute the full deterministic sequence in one call and emit a compact PASS/FAIL/SKIP summary plus captured error text for failed steps. README now references the scripts via markdown links with usage/examples; remediation prose and Azure Policy validation stay in prose.

Fixes microsoft#2501

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 357973ca-09a4-41f9-8aaf-197779042f34

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.

Pull request overview

This PR updates the azure-validate Terraform recipe to replace the manual multi-command “validation preflight sequence” with a single run-and-report script entrypoint (bash + PowerShell), reducing agent round-trips and making results easier to consume.

Changes:

  • Added validate-terraform.sh and validate-terraform.ps1 to run the deterministic Terraform preflight checks and emit PASS/FAIL/SKIP plus failure details.
  • Updated the Terraform recipe README to link to the scripts, provide usage/examples, and keep remediation guidance in prose.
  • Centralized template-variable scanning ({{ .Env.* }}) into the scripts to produce compact, actionable output.
Show a summary per file
File Description
plugin/skills/azure-validate/references/recipes/terraform/scripts/validate-terraform.sh Adds bash implementation of the preflight runner with per-step reporting and failure details.
plugin/skills/azure-validate/references/recipes/terraform/scripts/validate-terraform.ps1 Adds PowerShell implementation of the preflight runner with per-step reporting and failure details.
plugin/skills/azure-validate/references/recipes/terraform/README.md Switches documentation from manual step-by-step commands to script-based usage and output interpretation.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 7
  • Review effort level: Low

Comment thread plugin/skills/azure-validate/references/recipes/terraform/README.md Outdated
- Record explicit PASS/FAIL for subscription selection so a bad
  --subscription / -SubscriptionId fails the run instead of being silently ignored.
- Stream terraform output to a temp file and only read it back on failure,
  avoiding holding large `terraform plan` output in memory.
- Add a main.tfvars.json JSON-syntax check (issue microsoft#2501) that records PASS/FAIL/SKIP.
- Align the Azure CLI install hint with the call-style used elsewhere:
  mcp_azure_mcp_extension_cli_install(cli-type: "az").
- Drop the duplicate per-step console output; the summary table is now the single
  source of results.
- Update README step list and trim prose.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 357973ca-09a4-41f9-8aaf-197779042f34
@tmeschter
Tom Meschter (tmeschter) merged commit 2861c25 into microsoft:main Jul 17, 2026
12 checks passed
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.

Replace azure-validate skill Terraform validation preflight sequence with a script

3 participants