Skip to content

Commit 2c79eb6

Browse files
committed
Added randomness of rg name, links to ref docs
1 parent abc1bd8 commit 2c79eb6

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

quickstart/101-resource-group/main.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ provider "azurerm" {
1414
features {}
1515
}
1616

17+
resource "random_uuid" "uuid" {}
18+
1719
resource "azurerm_resource_group" "rg" {
18-
name = var.resource_group_name
19-
location = var.resource_group_location
20-
}
20+
name = "${var.resource_group_name_prefix}-${random_uuid.uuid.result}"
21+
location = var.resource_group_location
22+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "resource_group_name" {
2+
value = azurerm_resource_group.rg.name
3+
}

quickstart/101-resource-group/readme.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# Azure resource group
22

3-
This template deploys an Azure resource group.
3+
This template deploys an Azure resource group with a random name beginning with "rg-".
44

5-
## Resources
5+
## Terraform resource types
66

7-
| Terraform Resource Type | Description |
8-
| - | - |
9-
| `azurerm_resource_group` | The resource group all resources are deployed into |
7+
- [random_uuid](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid)
8+
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
109

1110
## Variables
1211

1312
| Name | Description |
1413
|-|-|
15-
| `name` | Name of the deployment |
16-
| `environment` | The depolyment environment name (used for postfixing resource names) |
17-
| `location` | The Azure Region to deploy these resources in |
14+
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random number so name is unique in your Azure subscription. |
15+
| `resource_group_location` | The Azure Region to deploy these resources in |
1816

1917
## Example
2018

quickstart/101-resource-group/variables.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
variable "resource_group_name" {
2-
default = "myResourceGroup"
1+
variable "resource_group_name_prefix" {
2+
default = "rg"
3+
description = "Prefix of the resource group name that's combined with a random number so name is unique in your Azure subscription."
34
}
45

56
variable "resource_group_location" {

0 commit comments

Comments
 (0)