Skip to content

Commit 77a4fab

Browse files
Add Terraform module for Azure DNS Zone creation (#29)
* DEVOPS-332 terraform module for DNs zone * dnszone terraform module DEVOPS-332 * DEVOPS-332 terraform module for DNs zone * DEVOPS-332 terraform module for DNs zone
1 parent d57407e commit 77a4fab

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

dns-zone/dnszone.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
resource "azurerm_resource_group" "dns_rg" {
2+
name = var.resource_group_name
3+
location = var.location
4+
tags = {
5+
Environment = upper(var.environment)
6+
Orchestrator = "Terraform"
7+
DisplayName = upper(var.resource_group_name)
8+
ApplicationName = lower(var.application_name)
9+
Temporary = upper(var.temporary)
10+
}
11+
}
12+
13+
resource "azurerm_dns_zone" "dns" {
14+
name = var.dns_zone_name
15+
resource_group_name = azurerm_resource_group.dns_rg.name
16+
17+
tags = {
18+
Environment = upper(var.environment)
19+
Orchestrator = "Terraform"
20+
DisplayName = upper(var.dns_zone_name)
21+
ApplicationName = lower(var.application_name)
22+
Temporary = upper(var.temporary)
23+
24+
}
25+
26+
depends_on = [azurerm_resource_group.dns_rg]
27+
}

dns-zone/output.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
output "resource_group" {
2+
description = "Azure DNS Zone resource group name"
3+
value = azurerm_resource_group.dns_rg.name
4+
}
5+
6+
output "dns_zone_name" {
7+
description = "Azure DNS zone name"
8+
value = azurerm_dns_zone.dns.name
9+
}
10+
11+
output "resource_group_location" {
12+
description = "Azure resource group location"
13+
value = azurerm_resource_group.dns_rg.location
14+
}
15+
16+
output "dns_zone_id" {
17+
description = "DNS zone ID"
18+
value = azurerm_dns_zone.dns.id
19+
20+
}
21+
22+
output "name_servers" {
23+
description = "Name servers for the DNS zone"
24+
value = azurerm_dns_zone.dns.name_servers
25+
26+
}

dns-zone/providers.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
terraform {
2+
required_version = "~> 1.3"
3+
required_providers {
4+
azurerm = {
5+
source = "hashicorp/azurerm"
6+
version = ">= 4.0"
7+
}
8+
random = {
9+
source = "hashicorp/random"
10+
version = ">= 3.1"
11+
}
12+
}
13+
}
14+
provider "azurerm" {
15+
features {}
16+
}

dns-zone/variables.tf

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
variable "resource_group_name" {
2+
type = string
3+
description = "Azure DNS Zone Rg"
4+
default = ""
5+
}
6+
7+
variable "location" {
8+
type = string
9+
description = "Azure DNS RG location"
10+
default = ""
11+
}
12+
13+
variable "dns_zone_name" {
14+
description = "Azure DNS Zone name"
15+
type = string
16+
default = ""
17+
}
18+
19+
20+
variable "environment" {
21+
default = "DEV"
22+
description = "Environment tag value in Azure"
23+
type = string
24+
validation {
25+
condition = contains(["DEV", "QA", "UAT", "PROD"], var.environment)
26+
error_message = "Environment value should be one among DEV or QA or UAT or PROD."
27+
}
28+
}
29+
30+
variable "application_name" {
31+
default = "devwithkrishna"
32+
description = "Azure application name tag"
33+
}
34+
35+
36+
variable "temporary" {
37+
default = "TRUE"
38+
description = "Temporary tag value in Azure"
39+
type = string
40+
validation {
41+
condition = contains(["TRUE", "FALSE"], upper(var.temporary))
42+
error_message = "The temporary tag value must be either 'TRUE' or 'FALSE'."
43+
}
44+
45+
}
46+

0 commit comments

Comments
 (0)