Skip to content

Commit

Permalink
Updates for RSG data source, zone namespace fixes (backup), add tags …
Browse files Browse the repository at this point in the history
…to VNet links and add new example/test (#52)

* updates for RSG and Zones

* pre-commit

* version updates

* pre-commit

* add new example and fix batch

* pre-commit

* fixes issue 53 - add tags to links

---------

Co-authored-by: github-actions[bot] <[email protected]>
  • Loading branch information
jtracey93 and github-actions[bot] authored Nov 4, 2024
1 parent 19ae6be commit 367184e
Show file tree
Hide file tree
Showing 16 changed files with 364 additions and 50 deletions.
19 changes: 0 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
{
"editor.bracketPairColorization.enabled": true,
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#f8a3fa",
"activityBar.background": "#f8a3fa",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#797607",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#f8a3fa",
"statusBar.background": "#f473f7",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#f043f4",
"statusBarItem.remoteBackground": "#f473f7",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#f473f7",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#f473f799",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#f473f7",
}
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.5)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (~> 3.71)
- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.116.0, < 4.0)

- <a name="requirement_modtm"></a> [modtm](#requirement\_modtm) (~> 0.3)

Expand All @@ -42,8 +42,8 @@ The following resources are used by this module:
- [azurerm_role_assignment.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
- [modtm_telemetry.telemetry](https://registry.terraform.io/providers/Azure/modtm/latest/docs/resources/telemetry) (resource)
- [random_uuid.telemetry](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid) (resource)
- [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source)
- [azurerm_client_config.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source)
- [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) (data source)
- [modtm_module_source.telemetry](https://registry.terraform.io/providers/Azure/modtm/latest/docs/data-sources/module_source) (data source)

<!-- markdownlint-disable MD013 -->
Expand Down Expand Up @@ -181,11 +181,8 @@ Default:
"azure_backup": {
"zone_name": "privatelink.{regionCode}.backup.windowsazure.com"
},
"azure_batch_account": {
"zone_name": "{regionName}.privatelink.batch.azure.com"
},
"azure_batch_node_mgmt": {
"zone_name": "{regionName}.service.privatelink.batch.azure.com"
"azure_batch": {
"zone_name": "privatelink.batch.azure.com"
},
"azure_bot_svc_bot": {
"zone_name": "privatelink.directline.botframework.com"
Expand Down Expand Up @@ -442,7 +439,7 @@ The following Modules are called:

Source: Azure/avm-res-network-privatednszone/azurerm

Version: 0.1.2
Version: 0.2.1

<!-- markdownlint-disable-next-line MD041 -->
## Data Collection
Expand Down
183 changes: 183 additions & 0 deletions examples/custom-zones-vnet-link-existing-rg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<!-- BEGIN_TF_DOCS -->
# Link Private DNS Zones to Virtual Networks and Deploy Private DNS Zones to an Existing Resource Group

This deploys the module in a more advanced and rarer configuration.

It will deploy custom private DNS zones into an existing Resource Group and will also link each of the Private DNS Zones to the Virtual Networks provided via a Private DNS Zone Virtual Network Link.

Also tags are added to all resources created by the module.

```hcl
terraform {
required_version = "~> 1.5"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.116.0, < 4.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}
provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}
data "azurerm_client_config" "current" {}
module "regions" {
source = "Azure/regions/azurerm"
version = "~> 0.3"
}
resource "random_integer" "region_index" {
max = length(module.regions.regions) - 1
min = 0
}
module "naming" {
source = "Azure/naming/azurerm"
version = "~> 0.3"
}
resource "azurerm_resource_group" "this" {
location = module.regions.regions[random_integer.region_index.result].name
name = module.naming.resource_group.name_unique
}
resource "azurerm_virtual_network" "this_1" {
address_space = ["10.0.1.0/24"]
location = azurerm_resource_group.this.location
name = "vnet1"
resource_group_name = azurerm_resource_group.this.name
}
resource "azurerm_virtual_network" "this_2" {
address_space = ["10.0.2.0/24"]
location = azurerm_resource_group.this.location
name = "vnet2"
resource_group_name = azurerm_resource_group.this.name
}
module "test" {
source = "../../"
# source = "Azure/avm-ptn-network-private-link-private-dns-zones/azurerm"
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
resource_group_creation_enabled = false
private_link_private_dns_zones = {
"custom_zone_1" = {
zone_name = "custom-example-1.int"
}
"custom_zone_2" = {
zone_name = "custom-example-2.local"
}
}
virtual_network_resource_ids_to_link_to = {
"vnet1" = {
vnet_resource_id = azurerm_virtual_network.this_1.id
}
"vnet2" = {
vnet_resource_id = azurerm_virtual_network.this_2.id
}
}
resource_group_role_assignments = {
"rbac-asi-1" = {
role_definition_id_or_name = "Reader"
principal_id = data.azurerm_client_config.current.object_id
skip_service_principal_aad_check = true
}
}
tags = {
"env" = "example"
"example-tag-key" = "example tag value"
}
enable_telemetry = var.enable_telemetry
}
```

<!-- markdownlint-disable MD033 -->
## Requirements

The following requirements are needed by this module:

- <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) (~> 1.5)

- <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) (>= 3.116.0, < 4.0)

- <a name="requirement_random"></a> [random](#requirement\_random) (~> 3.5)

## Resources

The following resources are used by this module:

- [azurerm_resource_group.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
- [azurerm_virtual_network.this_1](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) (resource)
- [azurerm_virtual_network.this_2](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_network) (resource)
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)
- [azurerm_client_config.current](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/client_config) (data source)

<!-- markdownlint-disable MD013 -->
## Required Inputs

No required inputs.

## Optional Inputs

The following input variables are optional (have default values):

### <a name="input_enable_telemetry"></a> [enable\_telemetry](#input\_enable\_telemetry)

Description: This variable controls whether or not telemetry is enabled for the module.
For more information see <https://aka.ms/avm/telemetryinfo>.
If it is set to false, then no telemetry will be collected.

Type: `bool`

Default: `true`

## Outputs

No outputs.

## Modules

The following Modules are called:

### <a name="module_naming"></a> [naming](#module\_naming)

Source: Azure/naming/azurerm

Version: ~> 0.3

### <a name="module_regions"></a> [regions](#module\_regions)

Source: Azure/regions/azurerm

Version: ~> 0.3

### <a name="module_test"></a> [test](#module\_test)

Source: ../../

Version:

<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
<!-- END_TF_DOCS -->
4 changes: 4 additions & 0 deletions examples/custom-zones-vnet-link-existing-rg/_footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- markdownlint-disable-next-line MD041 -->
## Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft’s privacy statement. Our privacy statement is located at <https://go.microsoft.com/fwlink/?LinkID=824704>. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
7 changes: 7 additions & 0 deletions examples/custom-zones-vnet-link-existing-rg/_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Link Private DNS Zones to Virtual Networks and Deploy Private DNS Zones to an Existing Resource Group

This deploys the module in a more advanced and rarer configuration.

It will deploy custom private DNS zones into an existing Resource Group and will also link each of the Private DNS Zones to the Virtual Networks provided via a Private DNS Zone Virtual Network Link.

Also tags are added to all resources created by the module.
100 changes: 100 additions & 0 deletions examples/custom-zones-vnet-link-existing-rg/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
terraform {
required_version = "~> 1.5"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.116.0, < 4.0"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}

provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
}
}

data "azurerm_client_config" "current" {}

module "regions" {
source = "Azure/regions/azurerm"
version = "~> 0.3"
}

resource "random_integer" "region_index" {
max = length(module.regions.regions) - 1
min = 0
}

module "naming" {
source = "Azure/naming/azurerm"
version = "~> 0.3"
}

resource "azurerm_resource_group" "this" {
location = module.regions.regions[random_integer.region_index.result].name
name = module.naming.resource_group.name_unique
}

resource "azurerm_virtual_network" "this_1" {
address_space = ["10.0.1.0/24"]
location = azurerm_resource_group.this.location
name = "vnet1"
resource_group_name = azurerm_resource_group.this.name
}

resource "azurerm_virtual_network" "this_2" {
address_space = ["10.0.2.0/24"]
location = azurerm_resource_group.this.location
name = "vnet2"
resource_group_name = azurerm_resource_group.this.name
}

module "test" {
source = "../../"
# source = "Azure/avm-ptn-network-private-link-private-dns-zones/azurerm"

location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name

resource_group_creation_enabled = false

private_link_private_dns_zones = {
"custom_zone_1" = {
zone_name = "custom-example-1.int"
}
"custom_zone_2" = {
zone_name = "custom-example-2.local"
}
}

virtual_network_resource_ids_to_link_to = {
"vnet1" = {
vnet_resource_id = azurerm_virtual_network.this_1.id
}
"vnet2" = {
vnet_resource_id = azurerm_virtual_network.this_2.id
}
}

resource_group_role_assignments = {
"rbac-asi-1" = {
role_definition_id_or_name = "Reader"
principal_id = data.azurerm_client_config.current.object_id
skip_service_principal_aad_check = true
}
}

tags = {
"env" = "example"
"example-tag-key" = "example tag value"
}

enable_telemetry = var.enable_telemetry
}
9 changes: 9 additions & 0 deletions examples/custom-zones-vnet-link-existing-rg/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "enable_telemetry" {
type = bool
default = true
description = <<DESCRIPTION
This variable controls whether or not telemetry is enabled for the module.
For more information see <https://aka.ms/avm/telemetryinfo>.
If it is set to false, then no telemetry will be collected.
DESCRIPTION
}
Loading

0 comments on commit 367184e

Please sign in to comment.