{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"generate-modern-terraform-code-for-azure","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Guidelines for generating modern Terraform code for Azure'\napplyTo: '**/*.tf'\n---\n\n## 1. Use Latest Terraform and Providers\nAlways target the latest stable Terraform version and Azure providers. In code, specify the required Terraform and provider versions to enforce this. Keep provider versions updated to get new features and fixes.\n\n## 2. Organize Code Cleanly\nStructure Terraform configurations with logical file separation:\n\n- Use `main.tf` for resources\n- Use `variables.tf` for inputs\n- Use `outputs.tf` for outputs\n- Follow consistent naming conventions and formatting (`terraform fmt`)\n\nThis makes the code easy to navigate and maintain.\n\n## 3. Encapsulate in Modules\n\nUse Terraform modules to group reusable infrastructure components. For any resource set that will be used in multiple contexts:\n\n- Create a module with its own variables/outputs\n- Reference it rather than duplicating code\n- This promotes reuse and consistency\n\n## 4. Leverage Variables and Outputs\n\n- **Parameterize** all configurable values using variables with types and descriptions\n- **Provide default values** where appropriate for optional variables\n- **Use outputs** to expose key resource attributes for other modules or user reference\n- **Mark sensitive values** accordingly to protect secrets\n\n## 5. Provider Selection (AzureRM vs AzAPI)\n\n- **Use `azurerm` provider** for most scenarios – it offers high stability and covers the majority of Azure services\n- **Use `azapi` provider** only for cases where you need:\n  - The very latest Azure features\n  - A resource not yet supported in `azurerm`\n- **Document the choice** in code comments\n- Both providers can be used together if needed, but prefer `azurerm` when in doubt\n\n## 6. Minimal Dependencies\n\n- **Do not introduce** additional providers or modules beyond the project's scope without confirmation\n- If a special provider (e.g., `random`, `tls`) or external module is needed:\n  - Add a comment to explain\n  - Ensure the user approves it\n- Keep the infrastructure stack lean and avoid unnecessary complexity\n\n## 7. Ensure Idempotency\n\n- Write configurations that can be applied repeatedly with the same outcome\n- **Avoid non-idempotent actions**:\n  - Scripts that run on every apply\n  - Resources that might conflict if created twice\n- **Test by doing multiple `terraform apply` runs** and ensure the second run results in zero changes\n- Use resource lifecycle settings or conditional expressions to handle drift or external changes gracefully\n\n## 8. State Management\n\n- **Use a remote backend** (like Azure Storage with state locking) to store Terraform state securely\n- Enable team collaboration\n- **Never commit state files** to source control\n- This prevents conflicts and keeps the infrastructure state consistent\n\n## 9. Document and Diagram\n\n- **Maintain up-to-date documentation**\n- **Update README.md** with any new variables, outputs, or usage instructions whenever the code changes\n- Consider using tools like `terraform-docs` for automation\n- **Update architecture diagrams** to reflect infrastructure changes after each significant update\n- Well-documented code and diagrams ensure the whole team understands the infrastructure\n\n## 10. Validate and Test Changes\n\n- **Run `terraform validate`** and review the `terraform plan` output before applying changes\n- Catch errors or unintended modifications early\n- **Consider implementing automated checks**:\n  - CI pipeline\n  - Pre-commit hooks\n  - Enforce formatting, linting, and basic validation\n","description":"Guidelines for generating modern Terraform code for Azure","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/generate-modern-terraform-code-for-azure.instructions.md"},"manifest":{}},"content_hash":[69,108,124,27,157,205,5,120,67,24,131,216,167,191,15,190,166,11,129,173,131,203,2,141,196,156,106,240,215,113,127,131],"trust_level":"unsigned","yanked":false}
