From 2c79eb6a2330836a6c39f0ab1f8f5a346c2a6900 Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Sat, 7 Aug 2021 22:17:06 -0700 Subject: [PATCH 1/3] Added randomness of rg name, links to ref docs --- quickstart/101-resource-group/main.tf | 8 +++++--- quickstart/101-resource-group/output.tf | 3 +++ quickstart/101-resource-group/readme.md | 14 ++++++-------- quickstart/101-resource-group/variables.tf | 5 +++-- 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 quickstart/101-resource-group/output.tf 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" { From a8ba805c8bbf3ff7b0c1a74dcf1f78984a4ca245 Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Wed, 29 Sep 2021 06:47:25 -0700 Subject: [PATCH 2/3] Implemented changes per review --- quickstart/101-resource-group/main.tf | 6 ++++-- quickstart/101-resource-group/readme.md | 4 ++-- quickstart/101-resource-group/variables.tf | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/quickstart/101-resource-group/main.tf b/quickstart/101-resource-group/main.tf index 808be901..77c1e183 100644 --- a/quickstart/101-resource-group/main.tf +++ b/quickstart/101-resource-group/main.tf @@ -14,9 +14,11 @@ provider "azurerm" { features {} } -resource "random_uuid" "uuid" {} +resource "random_pet" "rg-name" { + prefix = var.resource_group_name_prefix +} resource "azurerm_resource_group" "rg" { - name = "${var.resource_group_name_prefix}-${random_uuid.uuid.result}" + name = random_pet.rg-name.id location = var.resource_group_location } diff --git a/quickstart/101-resource-group/readme.md b/quickstart/101-resource-group/readme.md index b7cfc575..6d27ec6c 100644 --- a/quickstart/101-resource-group/readme.md +++ b/quickstart/101-resource-group/readme.md @@ -11,8 +11,8 @@ This template deploys an Azure resource group with a random name beginning with | Name | Description | |-|-| -| `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 | +| `resource_group_name_prefix` | (Optional) Prefix of the resource group name that's combined with a random number so name is unique in your Azure subscription. | +| `resource_group_location` | (Optional) 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 1145b5e2..1790a608 100644 --- a/quickstart/101-resource-group/variables.tf +++ b/quickstart/101-resource-group/variables.tf @@ -1,8 +1,9 @@ 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." + description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." } variable "resource_group_location" { default = "eastus" + description = "Location of the resource group." } From 01c7abe31b2899644c946bbeae918f8fb618245c Mon Sep 17 00:00:00 2001 From: Tom Archer Date: Thu, 30 Sep 2021 08:02:50 -0700 Subject: [PATCH 3/3] Changes per tech review --- quickstart/101-resource-group/readme.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quickstart/101-resource-group/readme.md b/quickstart/101-resource-group/readme.md index 6d27ec6c..84273e40 100644 --- a/quickstart/101-resource-group/readme.md +++ b/quickstart/101-resource-group/readme.md @@ -4,15 +4,15 @@ This template deploys an Azure resource group with a random name beginning with ## Terraform resource types -- [random_uuid](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) +- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet) - [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) ## Variables | Name | Description | |-|-| -| `resource_group_name_prefix` | (Optional) Prefix of the resource group name that's combined with a random number so name is unique in your Azure subscription. | -| `resource_group_location` | (Optional) The Azure Region to deploy these resources in | +| `resource_group_name_prefix` | (Optional) Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. Value defaults to: rg| +| `resource_group_location` | (Optional) Azure Region in which to deploy these resources. Value defaults to: eastus | ## Example