Added randomness of rg name, links to ref docs

This commit is contained in:
Tom Archer 2021-08-07 22:17:06 -07:00
parent abc1bd8bbe
commit 2c79eb6a23
4 changed files with 17 additions and 13 deletions

View File

@ -14,7 +14,9 @@ provider "azurerm" {
features {} features {}
} }
resource "random_uuid" "uuid" {}
resource "azurerm_resource_group" "rg" { resource "azurerm_resource_group" "rg" {
name = var.resource_group_name name = "${var.resource_group_name_prefix}-${random_uuid.uuid.result}"
location = var.resource_group_location location = var.resource_group_location
} }

View File

@ -0,0 +1,3 @@
output "resource_group_name" {
value = azurerm_resource_group.rg.name
}

View File

@ -1,20 +1,18 @@
# Azure resource group # 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 | - [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)
| `azurerm_resource_group` | The resource group all resources are deployed into |
## Variables ## Variables
| Name | Description | | Name | Description |
|-|-| |-|-|
| `name` | Name of the deployment | | `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. |
| `environment` | The depolyment environment name (used for postfixing resource names) | | `resource_group_location` | The Azure Region to deploy these resources in |
| `location` | The Azure Region to deploy these resources in |
## Example ## Example

View File

@ -1,5 +1,6 @@
variable "resource_group_name" { variable "resource_group_name_prefix" {
default = "myResourceGroup" 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" { variable "resource_group_location" {