From 8a88095951d08fe72fa11de17b7221cd6679f4eb Mon Sep 17 00:00:00 2001 From: Heng Lu Date: Tue, 26 Aug 2025 10:14:03 +0800 Subject: [PATCH] add terraform sample for resource group --- .../remarks/microsoft.resources/remarks.json | 7 ++++ .../samples/resourceGroups/main.tf | 27 +++++++++++++++ .../2024-07-01/resourcegroups.md | 33 +++++++++++++++++++ .../Generators/MarkdownGenerator.cs | 2 +- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 settings/remarks/microsoft.resources/samples/resourceGroups/main.tf diff --git a/settings/remarks/microsoft.resources/remarks.json b/settings/remarks/microsoft.resources/remarks.json index e7b872a7..05a6849f 100644 --- a/settings/remarks/microsoft.resources/remarks.json +++ b/settings/remarks/microsoft.resources/remarks.json @@ -7,6 +7,13 @@ "Description": "A basic example of deploying a resource group." } ], + "TerraformSamples": [ + { + "ResourceType": "microsoft.resources/resourceGroups", + "Path": "samples/resourceGroups/main.tf", + "Description": "A basic example of deploying a resource group." + } + ], "ResourceRemarks": [ { "ResourceTypes": [ diff --git a/settings/remarks/microsoft.resources/samples/resourceGroups/main.tf b/settings/remarks/microsoft.resources/samples/resourceGroups/main.tf new file mode 100644 index 00000000..582ea2d7 --- /dev/null +++ b/settings/remarks/microsoft.resources/samples/resourceGroups/main.tf @@ -0,0 +1,27 @@ +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + } +} + +provider "azapi" { + skip_provider_registration = false +} + +variable "resource_name" { + type = string + default = "acctest0001" +} + +variable "location" { + type = string + default = "westus" +} + +resource "azapi_resource" "resourceGroup" { + type = "Microsoft.Resources/resourceGroups@2020-06-01" + name = var.resource_name + location = var.location +} \ No newline at end of file diff --git a/src/TemplateRefGenerator.Tests/Files/markdown/microsoft.resources/2024-07-01/resourcegroups.md b/src/TemplateRefGenerator.Tests/Files/markdown/microsoft.resources/2024-07-01/resourcegroups.md index d6a7058f..d465a844 100644 --- a/src/TemplateRefGenerator.Tests/Files/markdown/microsoft.resources/2024-07-01/resourcegroups.md +++ b/src/TemplateRefGenerator.Tests/Files/markdown/microsoft.resources/2024-07-01/resourcegroups.md @@ -243,6 +243,39 @@ resource "azapi_resource" "symbolicname" { | ---- | ----------- | ------------ | ## Usage Examples +### Terraform Samples + +A basic example of deploying a resource group. + +```terraform +terraform { + required_providers { + azapi = { + source = "Azure/azapi" + } + } +} + +provider "azapi" { + skip_provider_registration = false +} + +variable "resource_name" { + type = string + default = "acctest0001" +} + +variable "location" { + type = string + default = "westus" +} + +resource "azapi_resource" "resourceGroup" { + type = "Microsoft.Resources/resourceGroups@2020-06-01" + name = var.resource_name + location = var.location +} +``` ### Azure Verified Modules The following [Azure Verified Modules](https://aka.ms/avm) can be used to deploy this resource type. diff --git a/src/TemplateRefGenerator/Generators/MarkdownGenerator.cs b/src/TemplateRefGenerator/Generators/MarkdownGenerator.cs index d0eca7cb..5f0b80b9 100644 --- a/src/TemplateRefGenerator/Generators/MarkdownGenerator.cs +++ b/src/TemplateRefGenerator/Generators/MarkdownGenerator.cs @@ -656,7 +656,7 @@ Set the **{discObjectType.Discriminator}** property to specify the type of objec sb.Append($""" {sample.Description} -```tf +```terraform {remarksLoader.GetCodeSample(resource.Provider, sample)} ```