Skip to content

Commit

Permalink
fix: Added comments and separate example for existing private dns zon…
Browse files Browse the repository at this point in the history
…e case
  • Loading branch information
13archit committed May 31, 2023
1 parent 4e0234a commit 871f952
Show file tree
Hide file tree
Showing 6 changed files with 304 additions and 79 deletions.
38 changes: 23 additions & 15 deletions _example/example.tf → _example/default/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ provider "azurerm" {
features {}
}

##-----------------------------------------------------------------------------
## Virtual Network module call.
## Virtual Network for which subnet will be created for private endpoint and vnet link will be created in private dns zone.
##-----------------------------------------------------------------------------
module "resource_group" {
source = "clouddrove/resource-group/azure"
version = "1.0.2"
Expand All @@ -11,7 +15,11 @@ module "resource_group" {
label_order = ["name", "environment"]
location = "East US"
}
#Vnet

##-----------------------------------------------------------------------------
## Resource Group module call
## Resource group in which all resources will be deployed.
##-----------------------------------------------------------------------------
module "vnet" {
depends_on = [module.resource_group]
source = "clouddrove/vnet/azure"
Expand All @@ -24,6 +32,10 @@ module "vnet" {
address_space = "10.0.0.0/16"
}

##-----------------------------------------------------------------------------
## Subnet module call.
## Subnet in which private endpoint will be created.
##-----------------------------------------------------------------------------
module "subnet" {
source = "clouddrove/subnet/azure"
version = "1.0.2"
Expand All @@ -48,28 +60,24 @@ module "subnet" {
]
}


##-----------------------------------------------------------------------------
## ACR module call.
##-----------------------------------------------------------------------------
module "container-registry" {
source = "../"
name = "test-acr"
name = "acr" # Name used for specifying tags and other resources naming.(like private endpoint, vnet-link etc)
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location

container_registry_config = {
name = "cdacr1234"
name = "cdacr1234" # Name of Container Registry
sku = "Premium"
}

# to enable private endpoint.
##-----------------------------------------------------------------------------
## To be mentioned for private endpoint, because private endpoint is enabled by default.
## To disable private endpoint set 'enable_private_endpoint' variable = false and than no need to specify following variable
##-----------------------------------------------------------------------------
virtual_network_id = join("", module.vnet.vnet_id)
subnet_id = module.subnet.default_subnet_id

########Following to be uncommnented only when using DNS Zone from different subscription along with existing DNS zone.

# diff_sub = true
# alias_sub = ""

#########Following to be uncommmented when using DNS zone from different resource group or different subscription.
# existing_private_dns_zone = ""
# existing_private_dns_zone_resource_group_name = ""
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
provider "azurerm" {
features {}
}

##-----------------------------------------------------------------------------
## Virtual Network module call.
## Virtual Network for which subnet will be created for private endpoint and vnet link will be created in private dns zone.
##-----------------------------------------------------------------------------
module "resource_group" {
source = "clouddrove/resource-group/azure"
version = "1.0.2"

name = "app"
environment = "test"
label_order = ["name", "environment"]
location = "East US"
}

##-----------------------------------------------------------------------------
## Resource Group module call
## Resource group in which all resources will be deployed.
##-----------------------------------------------------------------------------
module "vnet" {
depends_on = [module.resource_group]
source = "clouddrove/vnet/azure"
version = "1.0.2"

name = "app"
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
}

##-----------------------------------------------------------------------------
## Subnet module call.
## Subnet in which private endpoint will be created.
##-----------------------------------------------------------------------------
module "subnet" {
source = "clouddrove/subnet/azure"
version = "1.0.2"

name = "app"
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_name = join("", module.vnet.vnet_name)

#subnet
subnet_names = ["subnet1"]
subnet_prefixes = ["10.0.0.0/20"]

# route_table
routes = [
{
name = "rt-test"
address_prefix = "0.0.0.0/0"
next_hop_type = "Internet"
}
]
}


##-----------------------------------------------------------------------------
## ACR module call.
##-----------------------------------------------------------------------------
module "container-registry" {
source = "../"
name = "acr" # Name used for specifying tags and other resources naming.(like private endpoint, vnet-link etc)
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
container_registry_config = {
name = "cdacr1234" # Name of Container Registry
sku = "Premium"
}
##-----------------------------------------------------------------------------
## To be mentioned for private endpoint, because private endpoint is enabled by default.
## To disable private endpoint set 'enable_private_endpoint' variable = false and than no need to specify following variable
##-----------------------------------------------------------------------------
virtual_network_id = join("", module.vnet.vnet_id)
subnet_id = module.subnet.default_subnet_id
##-----------------------------------------------------------------------------
## Specify following variales when private dns zone is in same subscription but in different resource group
##-----------------------------------------------------------------------------
existing_private_dns_zone = "privatelink.azurecr.io" # Name of private dns zone remain same for acr.
existing_private_dns_zone_resource_group_name = "example_test_rg"
}
93 changes: 93 additions & 0 deletions _example/with_existing_dns_zone/dns_zone_in_diff_subs/example.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
provider "azurerm" {
features {}
}


##-----------------------------------------------------------------------------
## Virtual Network module call.
## Virtual Network in which subnet will be created for private endpoint and for which vnet link will be created in private dns zone.
##-----------------------------------------------------------------------------
module "resource_group" {
source = "clouddrove/resource-group/azure"
version = "1.0.2"

name = "app"
environment = "test"
label_order = ["name", "environment"]
location = "East US"
}


##-----------------------------------------------------------------------------
## Resource Group module call
## Resource group in which all resources will be deployed.
##-----------------------------------------------------------------------------
module "vnet" {
depends_on = [module.resource_group]
source = "clouddrove/vnet/azure"
version = "1.0.2"

name = "app"
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
address_space = "10.0.0.0/16"
}


##-----------------------------------------------------------------------------
## Subnet module call.
## Subnet in which private endpoint will be created.
##-----------------------------------------------------------------------------
module "subnet" {
source = "clouddrove/subnet/azure"
version = "1.0.2"

name = "app"
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
virtual_network_name = join("", module.vnet.vnet_name)

#subnet
subnet_names = ["subnet1"]
subnet_prefixes = ["10.0.0.0/20"]

# route_table
routes = [
{
name = "rt-test"
address_prefix = "0.0.0.0/0"
next_hop_type = "Internet"
}
]
}


##-----------------------------------------------------------------------------
## ACR module call.
##-----------------------------------------------------------------------------
module "container-registry" {
source = "../"
name = "acr" # Name used for specifying tags and other resources naming.(like private endpoint, vnet-link etc)
environment = "test"
resource_group_name = module.resource_group.resource_group_name
location = module.resource_group.resource_group_location
container_registry_config = {
name = "cdacr1234" # Name of Container Registry
sku = "Premium"
}
##-----------------------------------------------------------------------------
## To be mentioned for private endpoint, because private endpoint is enabled by default.
## To disable private endpoint set 'enable_private_endpoint' variable = false and than no need to specify following variable
##-----------------------------------------------------------------------------
virtual_network_id = join("", module.vnet.vnet_id)
subnet_id = module.subnet.default_subnet_id
##-----------------------------------------------------------------------------
## Specify following variales when private dns zone is in different subscription.
##-----------------------------------------------------------------------------
diff_sub = true
alias_sub = "35XXXXXXXXXXXX67" # Subcription id in which dns zone is present.
existing_private_dns_zone = "privatelink.azurecr.io" # Name of private dns zone remain same for acr.
existing_private_dns_zone_resource_group_name = "example_test_rg"
}
Loading

0 comments on commit 871f952

Please sign in to comment.