Skip to content

Commit 0ff7fc1

Browse files
authored
add terraform sample for resource group (#114)
Thanks @anthony-c-martin for the terraform sample placeholder! I opened this PR to add the first terraform sample. I'll open another PR to add the samples in bulk once this PR is merged.
1 parent 26b7c57 commit 0ff7fc1

4 files changed

Lines changed: 68 additions & 1 deletion

File tree

settings/remarks/microsoft.resources/remarks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
"Description": "A basic example of deploying a resource group."
88
}
99
],
10+
"TerraformSamples": [
11+
{
12+
"ResourceType": "microsoft.resources/resourceGroups",
13+
"Path": "samples/resourceGroups/main.tf",
14+
"Description": "A basic example of deploying a resource group."
15+
}
16+
],
1017
"ResourceRemarks": [
1118
{
1219
"ResourceTypes": [
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
terraform {
2+
required_providers {
3+
azapi = {
4+
source = "Azure/azapi"
5+
}
6+
}
7+
}
8+
9+
provider "azapi" {
10+
skip_provider_registration = false
11+
}
12+
13+
variable "resource_name" {
14+
type = string
15+
default = "acctest0001"
16+
}
17+
18+
variable "location" {
19+
type = string
20+
default = "westus"
21+
}
22+
23+
resource "azapi_resource" "resourceGroup" {
24+
type = "Microsoft.Resources/resourceGroups@2020-06-01"
25+
name = var.resource_name
26+
location = var.location
27+
}

src/TemplateRefGenerator.Tests/Files/markdown/microsoft.resources/2024-07-01/resourcegroups.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,39 @@ resource "azapi_resource" "symbolicname" {
243243
| ---- | ----------- | ------------ |
244244

245245
## Usage Examples
246+
### Terraform Samples
247+
248+
A basic example of deploying a resource group.
249+
250+
```terraform
251+
terraform {
252+
required_providers {
253+
azapi = {
254+
source = "Azure/azapi"
255+
}
256+
}
257+
}
258+
259+
provider "azapi" {
260+
skip_provider_registration = false
261+
}
262+
263+
variable "resource_name" {
264+
type = string
265+
default = "acctest0001"
266+
}
267+
268+
variable "location" {
269+
type = string
270+
default = "westus"
271+
}
272+
273+
resource "azapi_resource" "resourceGroup" {
274+
type = "Microsoft.Resources/resourceGroups@2020-06-01"
275+
name = var.resource_name
276+
location = var.location
277+
}
278+
```
246279
### Azure Verified Modules
247280

248281
The following [Azure Verified Modules](https://aka.ms/avm) can be used to deploy this resource type.

src/TemplateRefGenerator/Generators/MarkdownGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ Set the **{discObjectType.Discriminator}** property to specify the type of objec
656656
sb.Append($"""
657657
{sample.Description}
658658
659-
```tf
659+
```terraform
660660
{remarksLoader.GetCodeSample(resource.Provider, sample)}
661661
```
662662

0 commit comments

Comments
 (0)