From 6b9617bd33638ee23942f72b9ae6c7a6f5a053e4 Mon Sep 17 00:00:00 2001 From: Archit Chopra Date: Thu, 1 Jun 2023 13:38:28 +0530 Subject: [PATCH] fix: Added complete example for module and updated basic example --- _example/basic/example.tf | 63 ++------------------------- _example/complete/example.tf | 82 ++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 60 deletions(-) create mode 100644 _example/complete/example.tf diff --git a/_example/basic/example.tf b/_example/basic/example.tf index 0fc7ffd..a61c1ad 100644 --- a/_example/basic/example.tf +++ b/_example/basic/example.tf @@ -1,65 +1,8 @@ -provider "azurerm" { - features {} -} - locals { name = "app" environment = "test" } -##----------------------------------------------------------------------------- -## 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 = local.name - environment = local.environment - 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 = 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" -} - -##----------------------------------------------------------------------------- -## Subnet module call. -## Subnet in which private endpoint will be created. -##----------------------------------------------------------------------------- -module "subnet" { - source = "clouddrove/subnet/azure" - version = "1.0.2" - name = local.name - environment = local.environment - 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. ##----------------------------------------------------------------------------- @@ -77,6 +20,6 @@ module "container-registry" { ## 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 -} + virtual_network_id = "vnet_id" + subnet_id = "subnet_id" +} \ No newline at end of file diff --git a/_example/complete/example.tf b/_example/complete/example.tf new file mode 100644 index 0000000..0fc7ffd --- /dev/null +++ b/_example/complete/example.tf @@ -0,0 +1,82 @@ +provider "azurerm" { + features {} +} + +locals { + name = "app" + environment = "test" +} + +##----------------------------------------------------------------------------- +## 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 = local.name + environment = local.environment + 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 = 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" +} + +##----------------------------------------------------------------------------- +## Subnet module call. +## Subnet in which private endpoint will be created. +##----------------------------------------------------------------------------- +module "subnet" { + source = "clouddrove/subnet/azure" + version = "1.0.2" + name = local.name + environment = local.environment + 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 = local.name # Name used for specifying tags and other resources naming.(like private endpoint, vnet-link etc) + environment = local.environment + 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 +}