Edits per Code Review
This commit is contained in:
parent
f3b13826b1
commit
33a3b48bb5
29
quickstart/101-dns_zone/main.tf
Normal file
29
quickstart/101-dns_zone/main.tf
Normal file
@ -0,0 +1,29 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
name = random_pet.rg_name.id
|
||||
location = var.resource_group_location
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_dns_zone_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_dns_zone" "zone" {
|
||||
name = var.dns_zone_name != null ? var.dns_zone_name : "www.${random_string.azurerm_dns_zone_name.result}.azurequickstart.org"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
resource "azurerm_dns_a_record" "record" {
|
||||
name = "www"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
zone_name = azurerm_dns_zone.zone.name
|
||||
ttl = var.dns_ttl
|
||||
records = var.dns_records
|
||||
}
|
11
quickstart/101-dns_zone/outputs.tf
Normal file
11
quickstart/101-dns_zone/outputs.tf
Normal file
@ -0,0 +1,11 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "dns_zone_name" {
|
||||
value = azurerm_dns_zone.zone.name
|
||||
}
|
||||
|
||||
output "name_servers" {
|
||||
value = azurerm_dns_zone.zone.name_servers
|
||||
}
|
16
quickstart/101-dns_zone/providers.tf
Normal file
16
quickstart/101-dns_zone/providers.tf
Normal file
@ -0,0 +1,16 @@
|
||||
terraform {
|
||||
required_version = ">=1.0"
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>3.4"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
25
quickstart/101-dns_zone/readme.md
Normal file
25
quickstart/101-dns_zone/readme.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Azure DNS zone and A record
|
||||
|
||||
This template creates an Azure DNS zone and an 'A' record.
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [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)
|
||||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||
- [azurerm_dns_zone](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_zone)
|
||||
- [azurerm_dns_a_record](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_a_record)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
| `dns_zone_name` | Name of the DNS zone. | null |
|
||||
| `dns_ttl` | Time To Live (TTL) of the DNS record (in seconds). | 3600 |
|
||||
| `dns_records` | List of IPv4 addresses. | ["1.2.3.4", "1.2.3.5"] |
|
||||
|
||||
## Example
|
||||
|
||||
To see how to run this example, see [Create an Azure resource group using Terraform](https://docs.microsoft.com/azure/developer/terraform/create-resource-group).
|
29
quickstart/101-dns_zone/variables.tf
Normal file
29
quickstart/101-dns_zone/variables.tf
Normal file
@ -0,0 +1,29 @@
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location for all resources."
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random value so name is unique in your Azure subscription."
|
||||
}
|
||||
|
||||
variable "dns_zone_name" {
|
||||
type = string
|
||||
default = null
|
||||
description = "Name of the DNS zone."
|
||||
}
|
||||
|
||||
variable "dns_ttl" {
|
||||
type = number
|
||||
default = 3600
|
||||
description = "Time To Live (TTL) of the DNS record (in seconds)."
|
||||
}
|
||||
|
||||
variable "dns_records" {
|
||||
type = list(string)
|
||||
default = ["1.2.3.4", "1.2.3.5"]
|
||||
description = "List of IPv4 addresses."
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user