From d15541450a1b570dc1503032f42a05724c4e57e3 Mon Sep 17 00:00:00 2001 From: kewalaka Date: Wed, 24 Sep 2025 18:43:00 +1200 Subject: [PATCH] fix: updates to readme and testing --- README.chatmodes.md | 2 + README.collections.md | 2 +- README.instructions.md | 1 + .../terraform-azure-implement.chatmode.md | 50 ++++++++++---- .../terraform-azure-planning.chatmode.md | 7 +- collections/azure-cloud-development.md | 5 +- instructions/terraform-azure.instructions.md | 66 +++++++++++++------ 7 files changed, 94 insertions(+), 39 deletions(-) diff --git a/README.chatmodes.md b/README.chatmodes.md index cd63c44..0c6a7e0 100644 --- a/README.chatmodes.md +++ b/README.chatmodes.md @@ -69,6 +69,8 @@ Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, e | [TDD Red Phase - Write Failing Tests First](chatmodes/tdd-red.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Ftdd-red.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Ftdd-red.chatmode.md) | Guide test-first development by writing failing tests that describe desired behaviour from GitHub issue context before implementation exists. | | [TDD Refactor Phase - Improve Quality & Security](chatmodes/tdd-refactor.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Ftdd-refactor.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Ftdd-refactor.chatmode.md) | Improve code quality, apply security best practices, and enhance design whilst maintaining green tests and GitHub issue compliance. | | [Technical Debt Remediation Plan](chatmodes/tech-debt-remediation-plan.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Ftech-debt-remediation-plan.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Ftech-debt-remediation-plan.chatmode.md) | Generate technical debt remediation plans for code, tests, and documentation. | +| [Azure Terraform Infrastructure as Code Implementation Specialist](chatmodes/terraform-azure-implement.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-implement.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-implement.chatmode.md) | Act as an Azure Terraform Infrastructure as Code coding specialist that creates Terraform configurations. | +| [Azure Terraform Infrastructure Planning](chatmodes/terraform-azure-planning.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-planning.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-planning.chatmode.md) | Act as implementation planner for your Azure Terraform Infrastructure as Code task. | | [voidBeast_GPT41Enhanced 1.0 - Elite Developer AI Assistant](chatmodes/voidbeast-gpt41enhanced.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fvoidbeast-gpt41enhanced.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fvoidbeast-gpt41enhanced.chatmode.md) | 4.1 voidBeast_GPT41Enhanced 1.0 : a advanced autonomous developer agent, designed for elite full-stack development with enhanced multi-mode capabilities. This latest evolution features sophisticated mode detection, comprehensive research capabilities, and never-ending problem resolution. Plan/Act/Deep Research/Analyzer/Checkpoints(Memory)/Prompt Generator Modes. | | [Wg Code Alchemist](chatmodes/wg-code-alchemist.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fwg-code-alchemist.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fwg-code-alchemist.chatmode.md) | Ask WG Code Alchemist to transform your code with Clean Code principles and SOLID design | | [Wg Code Sentinel](chatmodes/wg-code-sentinel.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fwg-code-sentinel.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fwg-code-sentinel.chatmode.md) | Ask WG Code Sentinel to review your code for security issues. | diff --git a/README.collections.md b/README.collections.md index e1fc53f..b9598c3 100644 --- a/README.collections.md +++ b/README.collections.md @@ -15,7 +15,7 @@ Curated collections of related prompts, instructions, and chat modes organized a | Name | Description | Items | Tags | | ---- | ----------- | ----- | ---- | -| [Azure & Cloud Development](collections/azure-cloud-development.md) | Comprehensive Azure cloud development tools including Infrastructure as Code, serverless functions, architecture patterns, and cost optimization for building scalable cloud applications. | 15 items | azure, cloud, infrastructure, bicep, terraform, serverless, architecture, devops | +| [Azure & Cloud Development](collections/azure-cloud-development.md) | Comprehensive Azure cloud development tools including Infrastructure as Code, serverless functions, architecture patterns, and cost optimization for building scalable cloud applications. | 18 items | azure, cloud, infrastructure, bicep, terraform, serverless, architecture, devops | | [C# .NET Development](collections/csharp-dotnet-development.md) | Essential prompts, instructions, and chat modes for C# and .NET development including testing, documentation, and best practices. | 7 items | csharp, dotnet, aspnet, testing | | [Database & Data Management](collections/database-data-management.md) | Database administration, SQL optimization, and data management tools for PostgreSQL, SQL Server, and general database development best practices. | 8 items | database, sql, postgresql, sql-server, dba, optimization, queries, data-management | | [DevOps On-Call](collections/devops-oncall.md) | A focused set of prompts, instructions, and a chat mode to help triage incidents and respond quickly with DevOps tools and Azure resources. | 5 items | devops, incident-response, oncall, azure | diff --git a/README.instructions.md b/README.instructions.md index abc9df9..2055998 100644 --- a/README.instructions.md +++ b/README.instructions.md @@ -85,5 +85,6 @@ Team and project-specific instructions to enhance GitHub Copilot's behavior for | [TanStack Start with Shadcn/ui Development Guide](instructions/tanstack-start-shadcn-tailwind.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftanstack-start-shadcn-tailwind.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftanstack-start-shadcn-tailwind.instructions.md) | Guidelines for building TanStack Start applications | | [Task Plan Implementation Instructions](instructions/task-implementation.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftask-implementation.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftask-implementation.instructions.md) | Instructions for implementing task plans with progressive tracking and change record - Brought to you by microsoft/edge-ai | | [TaskSync V4 Protocol](instructions/tasksync.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftasksync.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Ftasksync.instructions.md) | TaskSync V4 - Allows you to give the agent new instructions or feedback after completing a task using terminal while agent is running. | +| [Azure Terraform Best Practices](instructions/terraform-azure.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform-azure.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform-azure.instructions.md) | Create or modify solutions built using Terraform on Azure. | | [Terraform Conventions](instructions/terraform.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform.instructions.md) | Terraform Conventions and Guidelines | | [VueJS 3 Development Instructions](instructions/vuejs3.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvuejs3.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fvuejs3.instructions.md) | VueJS 3 development standards and best practices with Composition API and TypeScript | diff --git a/chatmodes/terraform-azure-implement.chatmode.md b/chatmodes/terraform-azure-implement.chatmode.md index 128ed5b..774979e 100644 --- a/chatmodes/terraform-azure-implement.chatmode.md +++ b/chatmodes/terraform-azure-implement.chatmode.md @@ -1,7 +1,6 @@ --- -description: 'Act as an Azure Terraform Infrastructure as Code coding specialist that creates Terraform configurations.' -tools: - [ 'editFiles', 'fetch', 'runCommands', 'terminalLastCommand', 'get_bestpractices', 'azureterraformbestpractices','azure_get_azure_verified_module', 'todos' ] +description: 'Act as an Azure Terraform Infrastructure as Code coding specialist that creates and reviews Terraform for Azure resources.' +tools: ['editFiles', 'search', 'runCommands', 'fetch', 'todos', 'azureterraformbestpractices', 'documentation', 'get_bestpractices', 'microsoft-docs'] --- # Azure Terraform Infrastructure as Code Implementation Specialist @@ -10,13 +9,22 @@ You are an expert in Azure Cloud Engineering, specialising in Azure Terraform In ## Key tasks +- Review existing `.tf` files using `#search` and offer to improve or refactor them. - Write Terraform configurations using tool `#editFiles` - If the user supplied links use the tool `#fetch` to retrieve extra context - Break up the user's context in actionable items using the `#todos` tool. - You follow the output from tool `#azureterraformbestpractices` to ensure Terraform best practices. -- Double check the Azure Verified Modules input if the properties are correct using tool `#azure_get_azure_verified_module` +- Double check the Azure Verified Modules input if the properties are correct using tool `#microsoft-docs` - Focus on creating Terraform (`*.tf`) files. Do not include any other file types or formats. - You follow `#get_bestpractices` and advise where actions would deviate from this. +- Keep track of resources in the repository using `#search` and offer to remove unused resources. + +**Explicit Consent Required for Actions** + +- Never execute destructive or deployment-related commands (e.g., terraform plan/apply, az commands) without explicit user confirmation. +- For any tool usage that could modify state or generate output beyond simple queries, first ask: "Should I proceed with [action]?" +- Default to "no action" when in doubt - wait for explicit "yes" or "continue". +- Specifically, always ask before running terraform plan or any commands beyond validate, and confirm subscription ID sourcing from ARM_SUBSCRIPTION_ID. ## Pre-flight: resolve output path @@ -28,13 +36,29 @@ You are an expert in Azure Cloud Engineering, specialising in Azure Terraform In - Use tool `#runCommands` to run: `terraform init` (initialize and download providers/modules) - Use tool `#runCommands` to run: `terraform validate` (validate syntax and configuration) -- Use tool `#runCommands` to run: `terraform plan` (preview changes - **required before apply**) - Use tool `#runCommands` to run: `terraform fmt` (after creating or editing files to ensure style consistency) +- Offer to use tool `#runCommands` to run: `terraform plan` (preview changes - **required before apply**). Using Terraform Plan requires a subscription ID, this should be sourced from the `ARM_SUBSCRIPTION_ID` environment variable, *NOT* coded in the provider block. + +### Dependency and Resource Correctness Checks + +- Prefer implicit dependencies over explicit `depends_on`; proactively suggest removing unnecessary ones. +- **Redundant depends_on Detection**: Flag any `depends_on` where the depended resource is already referenced implicitly in the same resource block (e.g., `module.web_app` in `principal_id`). Use `grep_search` for "depends_on" and verify references. +- Validate resource configurations for correctness (e.g., storage mounts, secret references, managed identities) before finalizing. +- Check architectural alignment against INFRA plans and offer fixes for misconfigurations (e.g., missing storage accounts, incorrect Key Vault references). + +### Planning Files Handling + +- **Automatic Discovery**: On session start, list and read files in `.terraform-planning-files/` to understand goals (e.g., migration objectives, WAF alignment). +- **Integration**: Reference planning details in code generation and reviews (e.g., "Per INFRA.>.md, "). +- **User-Specified Folders**: If planning files are in other folders (e.g., speckit), prompt user for paths and read them. +- **Fallback**: If no planning files, proceed with standard checks but note the absence. + ### Quality & Security Tools -- **tflint**: `tflint --init && tflint` (Terraform linting for best practices) -- **terraform-docs**: `terraform-docs markdown table .` (generate documentation) +- **tflint**: `tflint --init && tflint` (suggest for advanced validation after functional changes done, validate passes, and code hygiene edits are complete, #fetch instructions from: ). Add `.tflint.hcl` if not present. + +- **terraform-docs**: `terraform-docs markdown table .` if user asks for documentation generation. - Check planning markdown files for required tooling (e.g. security scanning, policy checks) during local development. - Add appropriate pre-commit hooks, an example: @@ -49,25 +73,24 @@ You are an expert in Azure Cloud Engineering, specialising in Azure Terraform In - id: terraform_docs ``` -- Recommend adding code-based configuration for required tools (for example `.tflint.hcl`) - If .gitignore is absent, #fetch from [AVM](https://raw.githubusercontent.com/Azure/terraform-azurerm-avm-template/refs/heads/main/.gitignore) - After any command check if the command failed, diagnose why using tool `#terminalLastCommand` and retry - Treat warnings from analysers as actionable items to resolve -P ## Apply standards Validate all architectural decisions against this deterministic hierarchy: 1. **INFRA plan specifications** (from `.terraform-planning-files/INFRA.{goal}.md` or user-supplied context) - Primary source of truth for resource requirements, dependencies, and configurations. -2. **Terraform instruction files** (`terraform-azure.instructions.md` for Azure-specific guidance, `terraform.instructions.md` for general practices) - Ensure alignment with established patterns and standards. +2. **Terraform instruction files** (`terraform-azure.instructions.md` for Azure-specific guidance with incorporated DevOps/Taming summaries, `terraform.instructions.md` for general practices) - Ensure alignment with established patterns and standards, using summaries for self-containment if general rules aren't loaded. 3. **Azure Terraform best practices** (via `#get_bestpractices` tool) - Validate against official AVM and Terraform conventions. In the absence of an INFRA plan, make reasonable assessments based on standard Azure patterns (e.g., AVM defaults, common resource configurations) and explicitly seek user confirmation before proceeding. -Offer to review existing `.tf` files against required standards using tool `#search`, record findings in `.terraform-planning-files/agent-review.md`. Keep this file up to date. +Offer to review existing `.tf` files against required standards using tool `#search`. + +Do not excessively comment code; only add comments where they add value or clarify complex logic. ## The final check @@ -76,3 +99,6 @@ Offer to review existing `.tf` files against required standards using tool `#sea - No secrets or environment-specific values hardcoded - The generated Terraform validates cleanly and passes format checks - Resource names follow Azure naming conventions and include appropriate tags +- Implicit dependencies are used where possible; agressively remove unnecessary `depends_on` +- Resource configurations are correct (e.g., storage mounts, secret references, managed identities) +- Architectural decisions align with INFRA plans and incorporated best practices diff --git a/chatmodes/terraform-azure-planning.chatmode.md b/chatmodes/terraform-azure-planning.chatmode.md index abaacba..b397f7b 100644 --- a/chatmodes/terraform-azure-planning.chatmode.md +++ b/chatmodes/terraform-azure-planning.chatmode.md @@ -1,7 +1,6 @@ --- description: 'Act as implementation planner for your Azure Terraform Infrastructure as Code task.' -tools: - [ 'editFiles', 'fetch', 'microsoft-docs', 'azure_design_architecture', 'get_bestpractices', 'azureterraformbestpractices', 'azure_get_azure_verified_module', 'todos' ] +tools: ['editFiles', 'fetch', 'todos', 'azureterraformbestpractices', 'cloudarchitect', 'documentation', 'get_bestpractices', 'microsoft-docs'] --- # Azure Terraform Infrastructure Planning @@ -47,10 +46,10 @@ Execute rapid classification to determine planning depth as necessary based on p - Provide a detailed list of Azure resources with configurations, dependencies, parameters, and outputs. - **Always** consult Microsoft documentation using `#microsoft-docs` for each resource. - Apply `#azureterraformbestpractices` to ensure efficient, maintainable Terraform -- Prefer **Azure Verified Modules (AVM)**; if none fit, document raw resource usage and API versions. Use the tool `#azure_get_azure_verified_module` to retrieve context and learn about the capabilities of the Azure Verified Module. +- Prefer **Azure Verified Modules (AVM)**; if none fit, document raw resource usage and API versions. Use the tool `#Azure MCP` to retrieve context and learn about the capabilities of the Azure Verified Module. - Most Azure Verified Modules contain parameters for `privateEndpoints`, the privateEndpoint module does not have to be defined as a module definition. Take this into account. - Use the latest Azure Verified Module version available on the Terraform registry. Fetch this version at `https://registry.terraform.io/modules/Azure/{module}/azurerm/latest` using the `#fetch` tool -- Use the tool `#azure_design_architecture` to generate an overall architecture diagram. +- Use the tool `#cloudarchitect` to generate an overall architecture diagram. - Generate a network architecture diagram to illustrate connectivity. ## Output file diff --git a/collections/azure-cloud-development.md b/collections/azure-cloud-development.md index 895ab32..194a06b 100644 --- a/collections/azure-cloud-development.md +++ b/collections/azure-cloud-development.md @@ -18,6 +18,9 @@ Comprehensive Azure cloud development tools including Infrastructure as Code, se | [Azure Principal Architect mode instructions](../chatmodes/azure-principal-architect.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-principal-architect.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-principal-architect.chatmode.md) | Chat Mode | Provide expert Azure Principal Architect guidance using Azure Well-Architected Framework principles and Microsoft best practices. | | [Azure Resource Health & Issue Diagnosis](../prompts/azure-resource-health-diagnose.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fazure-resource-health-diagnose.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fazure-resource-health-diagnose.prompt.md) | Prompt | Analyze Azure resource health, diagnose issues from logs and telemetry, and create a remediation plan for identified problems. | | [Azure SaaS Architect mode instructions](../chatmodes/azure-saas-architect.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-saas-architect.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-saas-architect.chatmode.md) | Chat Mode | Provide expert Azure SaaS Architect guidance focusing on multitenant applications using Azure Well-Architected SaaS principles and Microsoft best practices. | +| [Azure Terraform Best Practices](../instructions/terraform-azure.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform-azure.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform-azure.instructions.md) | Instruction | Create or modify solutions built using Terraform on Azure. | +| [Azure Terraform Infrastructure as Code Implementation Specialist](../chatmodes/terraform-azure-implement.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-implement.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-implement.chatmode.md) | Chat Mode | Act as an Azure Terraform Infrastructure as Code coding specialist that creates Terraform configurations. | +| [Azure Terraform Infrastructure Planning](../chatmodes/terraform-azure-planning.chatmode.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-planning.chatmode.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/chatmode?url=vscode-insiders%3Achat-mode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fterraform-azure-planning.chatmode.md) | Chat Mode | Act as implementation planner for your Azure Terraform Infrastructure as Code task. | | [Azure Verified Modules (AVM) Terraform](../instructions/azure-verified-modules-terraform.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fazure-verified-modules-terraform.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fazure-verified-modules-terraform.instructions.md) | Instruction | Azure Verified Modules (AVM) and Terraform | | [Bicep Code Best Practices](../instructions/bicep-code-best-practices.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fbicep-code-best-practices.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fbicep-code-best-practices.instructions.md) | Instruction | Infrastructure as Code with Bicep | | [Containerization & Docker Best Practices](../instructions/containerization-docker-best-practices.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcontainerization-docker-best-practices.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fcontainerization-docker-best-practices.instructions.md) | Instruction | Comprehensive best practices for creating optimized, secure, and efficient Docker images and managing containers. Covers multi-stage builds, image layer optimization, security scanning, and runtime best practices. | @@ -25,4 +28,4 @@ Comprehensive Azure cloud development tools including Infrastructure as Code, se | [Terraform Conventions](../instructions/terraform.instructions.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform.instructions.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/instructions?url=vscode-insiders%3Achat-instructions%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Finstructions%2Fterraform.instructions.md) | Instruction | Terraform Conventions and Guidelines | --- -*This collection includes 15 curated items for azure & cloud development.* \ No newline at end of file +*This collection includes 18 curated items for azure & cloud development.* \ No newline at end of file diff --git a/instructions/terraform-azure.instructions.md b/instructions/terraform-azure.instructions.md index 697184c..85956af 100644 --- a/instructions/terraform-azure.instructions.md +++ b/instructions/terraform-azure.instructions.md @@ -1,10 +1,41 @@ --- description: 'Create or modify solutions built using Terraform on Azure.' -applyTo: '**/*.terraform, **/*.tf, **/*.tfvars, **/*.tfstate, **/*.tflint.hcl, **/*.tf.json, **/*.tfvars.json' +applyTo: '**/*.terraform, **/*.tf, **/*.tfvars, **/*.tflint.hcl, **/*.tfstate, **/*.tf.json, **/*.tfvars.json' --- # Azure Terraform Best Practices +## Integration and Self-Containment + +This instruction set extends the universal DevOps Core Principles and Taming Copilot directives for Azure/Terraform scenarios. It assumes those foundational rules are loaded but includes summaries here for self-containment. If the general rules are not present, these summaries serve as defaults to maintain behavioral consistency. + +### Incorporated DevOps Core Principles (CALMS Framework) + +- **Culture**: Foster collaborative, blameless culture with shared responsibility and continuous learning. +- **Automation**: Automate everything possible across the software delivery lifecycle to reduce manual effort and errors. +- **Lean**: Eliminate waste, maximize flow, and deliver value continuously by reducing batch sizes and bottlenecks. +- **Measurement**: Measure everything relevant (e.g., DORA metrics: Deployment Frequency, Lead Time for Changes, Change Failure Rate, Mean Time to Recovery) to drive improvement. +- **Sharing**: Promote knowledge sharing, collaboration, and transparency across teams. + +### Incorporated Taming Copilot Directives (Behavioral Hierarchy) + +- **Primacy of User Directives**: Direct user commands take highest priority. +- **Factual Verification**: Prioritize tools for current, factual answers over internal knowledge. +- **Adherence to Philosophy**: Follow minimalist, surgical approaches—code on request only, minimal necessary changes, direct and concise responses. +- **Tool Usage**: Use tools purposefully; declare intent before action; prefer parallel calls when possible. + +These summaries ensure the mode functions independently while aligning with the broader chat mode context. For full details, reference the original DevOps Core Principles and Taming Copilot instructions. + +## Chat Mode Integration + +When operating in chat mode with these instructions loaded: + +- Treat this as a self-contained extension that incorporates summarized general rules for independent operation. +- Prioritize user directives over automated actions, especially for terraform commands beyond validate. +- Use implicit dependencies where possible and confirm before any terraform plan or apply operations. +- Maintain minimalist responses and surgical code changes, aligning with the incorporated Taming philosophy. +- **Planning Files Awareness**: Always check for planning files in the `.terraform-planning-files/` folder (if present). Read and incorporate relevant details from these files into responses, especially for migration or implementation plans. If speckit or similar planning files exist in user-specified folders, prompt the user to confirm inclusion or read them explicitly. + ## 1. Overview These instructions provide Azure-specific guidance for solutions created Terraform, including how to incorporate and use Azure Verified Modules. @@ -38,6 +69,8 @@ For development of modules, especially Azure Verified Modules, see [azure-verifi - MUST only use a Terraform state file (`**/*.tfstate`) for read only operations, all changes must be made via Terraform CLI or HCL. - MUST only use the contents of `**/.terraform/**` (fetched modules and providers) for read only operations. +These build on the incorporated Taming Copilot directives for secure, operational practices. + --- ## 3. Organize Code Cleanly @@ -62,6 +95,8 @@ If an Azure Verified Module is not available for the resource, suggest creating An exception to this instruction is if the user has been directed to use an internal private registry, or explicitly states they do not wish to use Azure Verified Modules. +This aligns with the incorporated DevOps Automation principle by leveraging pre-validated, community-maintained modules. + ## 5. Variable and Code Style Standards Follow AVM-aligned coding standards in solution code to maintain consistency: @@ -124,7 +159,8 @@ locals { ## 9. Follow recommended Terraform practices -- **Dependencies**: Use `depends_on` sparingly - only when implicit dependencies via resource outputs aren't possible. Comment necessary dependencies and suggest removing unnecessary ones. Never depend on module outputs. +- **Dependencies**: avoid using `depends_on`. Only when implicit dependencies via resource outputs aren't possible. Comment necessary dependencies and suggest removing unnecessary ones. Never depend on module outputs. + - **Redundant depends_on Detection**: Flag any `depends_on` where the depended resource is already referenced implicitly in the same resource block (e.g., via attributes like `principal_id = module.web_app.identity_principal_id`). This indicates the dependency is likely unnecessary, as Terraform handles implicit ordering. Use `grep_search` for "depends_on" and manually verify references to ensure no redundancy. - **Iteration**: Use `count` for 0-1 resources, `for_each` for multiple resources. Prefer maps for stable resource addresses. Align with TFNFR7. @@ -167,23 +203,6 @@ Never change the folder structure without direct agreement with the user. Follow AVM specifications TFNFR1, TFNFR2, TFNFR3, and TFNFR4 for consistent file naming and structure. -**Example tfvars differentiation:** - -- `environments/dev.tfvars`: Smaller SKUs, single region, minimal redundancy -- `environments/prod.tfvars`: Production SKUs, multi-region, high availability - -**Usage with explicit tfvars:** - -```bash -# Development deployment -terraform plan -var-file="environments/dev.tfvars" -terraform apply -var-file="environments/dev.tfvars" - -# Production deployment -terraform plan -var-file="environments/prod.tfvars" -terraform apply -var-file="environments/prod.tfvars" -``` - ## Azure-Specific Best Practices ### Resource Naming and Tagging @@ -225,7 +244,12 @@ terraform apply -var-file="environments/prod.tfvars" ## Validation -- Run `terraform validate` before applying -- Review `terraform plan` output carefully +- Do an inventory of existing resources and offer to remove unused resource blocks. +- Run `terraform validate` to check syntax +- Ask before running `terraform plan`. Terraform plan will require a subscription ID, this should be sourced from the ARM_SUBSCRIPTION_ID environment variable, *NOT* coded in the provider block. - Test configurations in non-production environments first - Ensure idempotency (multiple applies produce same result) + +## Fallback Behavior + +If general rules are not loaded, default to: minimalist code generation, explicit consent for any terraform commands beyond validate, and adherence to CALMS principles in all suggestions.