diff --git a/quickstart/101-resource-group/main.tf b/quickstart/101-resource-group/main.tf index 00e05541..808be901 100644 --- a/quickstart/101-resource-group/main.tf +++ b/quickstart/101-resource-group/main.tf @@ -14,7 +14,9 @@ provider "azurerm" { features {} } +resource "random_uuid" "uuid" {} + resource "azurerm_resource_group" "rg" { - name = var.resource_group_name - location = var.resource_group_location -} \ No newline at end of file + name = "${var.resource_group_name_prefix}-${random_uuid.uuid.result}" + location = var.resource_group_location +} diff --git a/quickstart/101-resource-group/output.tf b/quickstart/101-resource-group/output.tf new file mode 100644 index 00000000..2de7782a --- /dev/null +++ b/quickstart/101-resource-group/output.tf @@ -0,0 +1,3 @@ +output "resource_group_name" { + value = azurerm_resource_group.rg.name +} diff --git a/quickstart/101-resource-group/readme.md b/quickstart/101-resource-group/readme.md index 339448e3..b7cfc575 100644 --- a/quickstart/101-resource-group/readme.md +++ b/quickstart/101-resource-group/readme.md @@ -1,20 +1,18 @@ # Azure resource group -This template deploys an Azure resource group. +This template deploys an Azure resource group with a random name beginning with "rg-". -## Resources +## Terraform resource types -| Terraform Resource Type | Description | -| - | - | -| `azurerm_resource_group` | The resource group all resources are deployed into | +- [random_uuid](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) +- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) ## Variables | Name | Description | |-|-| -| `name` | Name of the deployment | -| `environment` | The depolyment environment name (used for postfixing resource names) | -| `location` | The Azure Region to deploy these resources in | +| `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. | +| `resource_group_location` | The Azure Region to deploy these resources in | ## Example diff --git a/quickstart/101-resource-group/variables.tf b/quickstart/101-resource-group/variables.tf index 82531797..1145b5e2 100644 --- a/quickstart/101-resource-group/variables.tf +++ b/quickstart/101-resource-group/variables.tf @@ -1,5 +1,6 @@ -variable "resource_group_name" { - default = "myResourceGroup" +variable "resource_group_name_prefix" { + default = "rg" + description = "Prefix of the resource group name that's combined with a random number so name is unique in your Azure subscription." } variable "resource_group_location" {