Skip to content

Commit

Permalink
fix: Added comments and updates example folder hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
13archit committed Jul 12, 2023
1 parent 7459bda commit b49764f
Show file tree
Hide file tree
Showing 8 changed files with 211 additions and 20 deletions.
43 changes: 42 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,52 @@

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 3
assignees:
- "clouddrove-ci"
reviewers:
- "approvers"

- package-ecosystem: "terraform" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
assignees:
- "clouddrove-ci"
# Add reviewer
reviewers:
- "approvers"
# Allow up to 3 open pull requests for pip dependencies
open-pull-requests-limit: 3

- package-ecosystem: "terraform" # See documentation for possible values
directory: "/_example/basic" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
assignees:
- "clouddrove-ci"
# Add reviewer
reviewers:
- "approvers"
# Allow up to 3 open pull requests for pip dependencies
open-pull-requests-limit: 3

- package-ecosystem: "terraform" # See documentation for possible values
directory: "_example/" # Location of package manifests
directory: "/_example/complete" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
assignees:
- "clouddrove-ci"
# Add reviewer
reviewers:
- "approvers"
# Allow up to 3 open pull requests for pip dependencies
open-pull-requests-limit: 3
3 changes: 2 additions & 1 deletion .github/workflows/static-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory:
- _example/
- _example/basic
- _example/complete

steps:
- name: Checkout
Expand Down
38 changes: 38 additions & 0 deletions _example/basic/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##-----------------------------------------------------------------------------
## DNS zone module call
## Below module will deploy public dns in azure.
##-----------------------------------------------------------------------------
module "dns_zone" {
depends_on = [module.resource_group, module.vnet]
source = "../.."
name = "app"
environment = "test"
resource_group_name = "test-rg"
dns_zone_names = "example.com"
private_registration_enabled = false
private_dns = false
private_dns_zone_name = ""
virtual_network_id = "/subscriptions/---------------------------"
a_records = [{
name = "test"
ttl = 3600
records = ["10.0.180.17", "10.0.180.18"]
},
{
name = "test2"
ttl = 3600
records = ["10.0.180.17", "10.0.180.18"]
}]

cname_records = [{
name = "test1"
ttl = 3600
record = "example.com"
}]

ns_records = [{
name = "test2"
ttl = 3600
records = ["ns1.example.com.", "ns2.example.com."]
}]
}
File renamed without changes.
33 changes: 24 additions & 9 deletions _example/example.tf → _example/complete/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,48 @@ provider "azurerm" {
features {}
}

locals {
name = "app"
environment = "test"
label_order = ["name", "environment", ]
}

##-----------------------------------------------------------------------------
## Resource Group module call
## Resource group in which all resources will be deployed.
##-----------------------------------------------------------------------------
module "resource_group" {
source = "clouddrove/resource-group/azure"
version = "1.0.2"
name = "app"
environment = "test"
label_order = ["name", "environment", ]
name = local.name
environment = local.environment
label_order = local.label_order
location = "East US"
}

##-----------------------------------------------------------------------------
## Vnet module call
##-----------------------------------------------------------------------------
module "vnet" {
depends_on = [module.resource_group]
source = "clouddrove/vnet/azure"
version = "1.0.3"
name = "app"
environment = "test"
name = local.name
environment = local.environment
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
}

##-----------------------------------------------------------------------------
## DNS zone module call
## Below module will deploy public dns in azure.
##-----------------------------------------------------------------------------
module "dns_zone" {
depends_on = [module.resource_group, module.vnet]
source = "../"
name = "app"
environment = "test"
source = "../.."
name = local.name
environment = local.environment
resource_group_name = module.resource_group.resource_group_name
dns_zone_names = "example.com"
private_registration_enabled = false
Expand Down Expand Up @@ -56,5 +72,4 @@ module "dns_zone" {
ttl = 3600
records = ["ns1.example.com.", "ns2.example.com."]
}]

}
79 changes: 79 additions & 0 deletions _example/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
output "dns_zone_id" {
description = "The DNS Zone ID."
value = module.dns_zone.dns_zone_id
}

output "dns_zone_number_of_record_sets" {
description = "The number of records already in the zone."
value = module.dns_zone.dns_zone_number_of_record_sets
}

output "dns_zone_name_servers" {
description = " A list of values that make up the NS record for the zone."
value = module.dns_zone.dns_zone_name_servers
}

output "dns_zone_max_number_of_record_sets" {
description = " Maximum number of Records in the zone. Defaults to 1000."
value = module.dns_zone.dns_zone_max_number_of_record_sets
}

output "private_dns_zone_id" {
description = "The Private DNS Zone ID."
value = module.dns_zone.private_dns_zone_id
}

output "private_dns_zone_number_of_record_sets" {
description = "The current number of record sets in this Private DNS zone."
value = module.dns_zone.private_dns_zone_number_of_record_sets
}

output "private_dns_zone_max_number_of_record_sets" {
description = "The maximum number of record sets that can be created in this Private DNS zone."
value = module.dns_zone.private_dns_zone_max_number_of_record_sets
}

output "private_dns_zone_max_number_of_virtual_network_links" {
description = "The maximum number of virtual networks that can be linked to this Private DNS zone."
value = module.dns_zone.private_dns_zone_max_number_of_virtual_network_links
}

output "private_dns_zone_max_number_of_virtual_network_links_with_registration" {
description = "The maximum number of virtual networks that can be linked to this Private DNS zone with registration enabled."
value = module.dns_zone.private_dns_zone_max_number_of_virtual_network_links_with_registration
}

output "private_dns_zone_virtual_network_link_id" {
description = "The ID of the Private DNS Zone Virtual Network Link."
value = module.dns_zone.private_dns_zone_virtual_network_link_id
}

output "dns_a_record_id" {
description = " The DNS A Record ID."
value = module.dns_zone.dns_a_record_id
}

output "dns_a_record_fqdn" {
description = "The FQDN of the DNS A Record."
value = module.dns_zone.dns_a_record_fqdn
}

output "dns_cname_record_id" {
description = " The DNS CNAME Record ID."
value = module.dns_zone.dns_cname_record_id
}

output "dns_cname_record_fqdn" {
description = "The FQDN of the DNS CNAME Record."
value = module.dns_zone.dns_cname_record_fqdn
}

output "dns_ns_record_id" {
description = " The DNS NS Record ID."
value = module.dns_zone.dns_ns_record_id
}

output "dns_ns_record_fqdn" {
description = "The FQDN of the DNS NS Record."
value = module.dns_zone.dns_ns_record_fqdn
}
26 changes: 24 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
##-----------------------------------------------------------------------------
## Labels module callled that will be used for naming and tags.
##-----------------------------------------------------------------------------
module "labels" {
source = "clouddrove/labels/azure"
name = var.name
Expand All @@ -7,11 +10,16 @@ module "labels" {
repository = var.repository
}


##-----------------------------------------------------------------------------
## Below resource will deploy random id that will be used for naming in vnet link resource for private dns.
##-----------------------------------------------------------------------------
resource "random_id" "this" {
byte_length = "8"
}

##-----------------------------------------------------------------------------
## Below resource will deploy public DNS zone in azure.
##-----------------------------------------------------------------------------
resource "azurerm_dns_zone" "dns_zone" {
count = var.enabled && var.enabled_dns ? 1 : 0
name = var.dns_zone_names
Expand All @@ -20,6 +28,9 @@ resource "azurerm_dns_zone" "dns_zone" {

}

##-----------------------------------------------------------------------------
## Below resource will deploy private DNS zone in azure.
##-----------------------------------------------------------------------------
resource "azurerm_private_dns_zone" "private_dns_zone" {
count = var.enabled && var.private_dns ? 1 : 0
name = var.private_dns_zone_name
Expand All @@ -38,6 +49,9 @@ resource "azurerm_private_dns_zone" "private_dns_zone" {
tags = module.labels.tags
}

##-----------------------------------------------------------------------------
## Below resource will deploy vnet link in private dns zone.
##-----------------------------------------------------------------------------
resource "azurerm_private_dns_zone_virtual_network_link" "private_dns_vnet_link" {
count = var.enabled && var.private_dns ? 1 : 0
name = "vnet-link-${random_id.this.hex}"
Expand All @@ -48,7 +62,9 @@ resource "azurerm_private_dns_zone_virtual_network_link" "private_dns_vnet_link"
tags = module.labels.tags
}


##-----------------------------------------------------------------------------
## Below resource will add a_record in DNS zone.
##-----------------------------------------------------------------------------
resource "azurerm_dns_a_record" "records_a" {
for_each = { for record in var.a_records : record.name => record }
name = lookup(each.value, "name", null) # Required
Expand All @@ -60,6 +76,9 @@ resource "azurerm_dns_a_record" "records_a" {
tags = module.labels.tags
}

##-----------------------------------------------------------------------------
## Below resource will add cname_record in DNS zone.
##-----------------------------------------------------------------------------
resource "azurerm_dns_cname_record" "records_cname" {
for_each = { for record in var.cname_records : record.name => record } #toset(var.cname_records)
name = lookup(each.value, "name", null) # Required
Expand All @@ -72,6 +91,9 @@ resource "azurerm_dns_cname_record" "records_cname" {

}

##-----------------------------------------------------------------------------
## Below resource will add ns_record in DNS zone.
##-----------------------------------------------------------------------------
resource "azurerm_dns_ns_record" "records_ns" {
for_each = { for record in var.ns_records : record.name => record } #toset(var.ns_records)

Expand Down
9 changes: 2 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,13 @@ variable "soa_record" {

variable "a_records" {
type = any
default = []
description = "List of a records to be added in azure dns zone."
}

variable "cname_records" {
type = any
# type = list(object({
# name = string, #(Required)The name of the DNS CNAME Record. Changing this forces a new resource to be created.
# ttl = number, #(Required)The Time To Live (TTL) of the DNS record in seconds.
# record = string, #(Optional)The target of the CNAME.
# target_resource_id = string #(Optional)The Azure resource id of the target object. Conflicts with record.
# }))
# default = []
default = []
description = "List of cname records"
}

Expand Down

0 comments on commit b49764f

Please sign in to comment.