Skip to content

Commit

Permalink
v0.3.0 (#56)
Browse files Browse the repository at this point in the history
* fixed module_name locals

* added private link scope file in root, created new network isolation example.

* fixed formatting and linting

* updating formatting

* fixed variable

* removed variable

* avm fix

* updated variables and examples

* add for_each

* fixed example

* fixed linting

* updating linting errors

* fixed linting error
  • Loading branch information
cshea-msft authored Jun 26, 2024
1 parent 5bf79b0 commit 68f61b4
Show file tree
Hide file tree
Showing 16 changed files with 447 additions and 62 deletions.
39 changes: 31 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ The following resources are used by this module:
- [azurerm_log_analytics_workspace.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/log_analytics_workspace) (resource)
- [azurerm_management_lock.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
- [azurerm_monitor_diagnostic_setting.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_diagnostic_setting) (resource)
- [azurerm_monitor_private_link_scope.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_private_link_scope) (resource)
- [azurerm_monitor_private_link_scoped_service.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/monitor_private_link_scoped_service) (resource)
- [azurerm_private_endpoint.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint) (resource)
- [azurerm_private_endpoint_application_security_group_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/private_endpoint_application_security_group_association) (resource)
- [azurerm_resource_group_template_deployment.telemetry](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group_template_deployment) (resource)
Expand Down Expand Up @@ -258,6 +260,35 @@ object({

Default: `null`

### <a name="input_monitor_private_link_scope"></a> [monitor\_private\_link\_scope](#input\_monitor\_private\_link\_scope)

Description: A map of objects representing Azure Monitor Private Link Scopes. Each object can contain the following attributes:
- ingestion\_access\_mode: (Optional) The default ingestion access mode for the associated private endpoints in scope. Possible values are 'Open' and 'PrivateOnly'. Defaults to 'Open'.
- name: The name of the Azure Monitor Private Link Scope. Changing this forces a new resource to be created.
- query\_access\_mode: (Optional) The default query access mode for the associated private endpoints in scope. Possible values are 'Open' and 'PrivateOnly'. Defaults to 'Open'.
- tags: (Optional) A mapping of tags which should be assigned to the Azure Monitor Private Link Scope.

Type:

```hcl
map(object({
ingestion_access_mode = optional(string, "PrivateOnly")
name = optional(string, null)
query_access_mode = optional(string, "PrivateOnly")
tags = optional(map(string), null)
}))
```

Default: `{}`

### <a name="input_monitor_private_link_scoped_service_name"></a> [monitor\_private\_link\_scoped\_service\_name](#input\_monitor\_private\_link\_scoped\_service\_name)

Description: (Required) The name of the Azure Monitor Private Link Scoped Service. Changing this forces a new resource to be created.

Type: `string`

Default: `null`

### <a name="input_private_endpoints"></a> [private\_endpoints](#input\_private\_endpoints)

Description: A map of private endpoints to create on the Key Vault. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.
Expand Down Expand Up @@ -315,14 +346,6 @@ map(object({

Default: `{}`

### <a name="input_private_endpoints_manage_dns_zone_group"></a> [private\_endpoints\_manage\_dns\_zone\_group](#input\_private\_endpoints\_manage\_dns\_zone\_group)

Description: Whether to manage private DNS zone groups with this module. If set to false, you must manage private DNS zone groups externally, e.g. using Azure Policy.

Type: `bool`

Default: `true`

### <a name="input_role_assignments"></a> [role\_assignments](#input\_role\_assignments)

Description: A map of role assignments to create on the <RESOURCE>. The map key is deliberately arbitrary to avoid issues where map keys maybe unknown at plan time.
Expand Down
2 changes: 1 addition & 1 deletion examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ module "log_analytics_workspace" {
log_analytics_workspace_identity = {
type = "SystemAssigned"
}
}
}
192 changes: 192 additions & 0 deletions examples/deploy_network_isolation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
<!-- BEGIN_TF_DOCS -->
# Deploy Network Isolation

This examples deploys network isolation with log analytics workspace using Private Endpoints and Azure Monitor Private Link Service.

- Log Analytics Workspace
- Private Endpoint
- Virtual Network
- Subnet
- Private DNS Zone
- Azure Monitor Private Link Scope
- Azure Monitor Private Link Scope Service

```hcl
terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.0, < 4.0.0"
}
}
}
provider "azurerm" {
features {}
}
# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
version = "0.3.0"
}
# This picks a random region from the list of regions.
resource "random_integer" "region_index" {
max = length(local.azure_regions) - 1
min = 0
}
# This is required for resource modules
resource "azurerm_resource_group" "this" {
location = local.azure_regions[random_integer.region_index.result]
name = module.naming.resource_group.name_unique
}
module "vnet" {
source = "Azure/avm-res-network-virtualnetwork/azurerm"
version = "~> 0.2.3"
name = module.naming.virtual_network.name_unique
resource_group_name = azurerm_resource_group.this.name
location = azurerm_resource_group.this.location
address_space = ["10.0.0.0/16"]
subnets = {
subnet0 = {
name = module.naming.subnet.name_unique
address_prefixes = ["10.0.0.0/24"]
}
}
}
module "privatednszone" {
source = "Azure/avm-res-network-privatednszone/azurerm"
version = "~> 0.1.1"
domain_name = "privatelink.workspace.azure.net"
resource_group_name = azurerm_resource_group.this.name
virtual_network_links = {
vnetlink0 = {
vnetlinkname = "dnslinktovnet"
vnetid = module.vnet.resource.id
}
}
}
# This is the module call
module "law" {
source = "../../"
# source = "Azure/avm-res-operationalinsights-workspace/azurerm"
enable_telemetry = var.enable_telemetry
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
name = "thislaworkspace"
log_analytics_workspace_retention_in_days = 30
log_analytics_workspace_sku = "PerGB2018"
log_analytics_workspace_identity = {
type = "SystemAssigned"
}
monitor_private_link_scope = {
scope0 = {
name = "law_pl_scope"
ingestion_access_mode = "PrivateOnly"
query_access_mode = "PrivateOnly"
}
}
monitor_private_link_scoped_service_name = "law_pl_service"
private_endpoints = {
pe1 = {
name = module.naming.private_endpoint.name_unique
subnet_resource_id = module.vnet.subnets["subnet0"].resource.id
private_dns_zone_resource_ids = [module.privatednszone.private_dnz_zone_output.id]
network_interface_name = "nic-pe-law"
}
}
}
```

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

The following requirements are needed by this module:

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

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

- <a name="requirement_random"></a> [random](#requirement\_random) (>= 3.5.0, < 4.0.0)

## Providers

The following providers are used by this module:

- <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) (>= 3.7.0, < 4.0.0)

- <a name="provider_random"></a> [random](#provider\_random) (>= 3.5.0, < 4.0.0)

## 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)
- [random_integer.region_index](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer) (resource)

<!-- 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_law"></a> [law](#module\_law)

Source: ../../

Version:

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

Source: Azure/naming/azurerm

Version: 0.3.0

### <a name="module_privatednszone"></a> [privatednszone](#module\_privatednszone)

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

Version: ~> 0.1.1

### <a name="module_vnet"></a> [vnet](#module\_vnet)

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

Version: ~> 0.2.3

<!-- 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/deploy_network_isolation/_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.
11 changes: 11 additions & 0 deletions examples/deploy_network_isolation/_header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Deploy Network Isolation

This examples deploys network isolation with log analytics workspace using Private Endpoints and Azure Monitor Private Link Service.

- Log Analytics Workspace
- Private Endpoint
- Virtual Network
- Subnet
- Private DNS Zone
- Azure Monitor Private Link Scope
- Azure Monitor Private Link Scope Service
15 changes: 15 additions & 0 deletions examples/deploy_network_isolation/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locals {
azure_regions = [
"westeurope",
"northeurope",
"eastus",
"eastus2",
"westus",
"westus2",
"southcentralus",
"northcentralus",
"centralus",
"eastasia",
"southeastasia",
]
}
94 changes: 94 additions & 0 deletions examples/deploy_network_isolation/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
terraform {
required_version = ">= 1.3.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.7.0, < 4.0.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.5.0, < 4.0.0"
}
}
}

provider "azurerm" {
features {}
}

# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
version = "0.3.0"
}

# This picks a random region from the list of regions.
resource "random_integer" "region_index" {
max = length(local.azure_regions) - 1
min = 0
}

# This is required for resource modules
resource "azurerm_resource_group" "this" {
location = local.azure_regions[random_integer.region_index.result]
name = module.naming.resource_group.name_unique
}

module "vnet" {
source = "Azure/avm-res-network-virtualnetwork/azurerm"
version = "~> 0.2.3"
name = module.naming.virtual_network.name_unique
resource_group_name = azurerm_resource_group.this.name
location = azurerm_resource_group.this.location
address_space = ["10.0.0.0/16"]
subnets = {
subnet0 = {
name = module.naming.subnet.name_unique
address_prefixes = ["10.0.0.0/24"]
}
}
}

module "privatednszone" {
source = "Azure/avm-res-network-privatednszone/azurerm"
version = "~> 0.1.1"
domain_name = "privatelink.workspace.azure.net"
resource_group_name = azurerm_resource_group.this.name
virtual_network_links = {
vnetlink0 = {
vnetlinkname = "dnslinktovnet"
vnetid = module.vnet.resource.id
}
}
}

# This is the module call
module "law" {
source = "../../"
# source = "Azure/avm-res-operationalinsights-workspace/azurerm"
enable_telemetry = var.enable_telemetry
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
name = "thislaworkspace"
log_analytics_workspace_retention_in_days = 30
log_analytics_workspace_sku = "PerGB2018"
log_analytics_workspace_identity = {
type = "SystemAssigned"
}
monitor_private_link_scope = {
scope0 = {
name = "law_pl_scope"
ingestion_access_mode = "PrivateOnly"
query_access_mode = "PrivateOnly"
}
}
monitor_private_link_scoped_service_name = "law_pl_service"
private_endpoints = {
pe1 = {
name = module.naming.private_endpoint.name_unique
subnet_resource_id = module.vnet.subnets["subnet0"].resource.id
private_dns_zone_resource_ids = [module.privatednszone.private_dnz_zone_output.id]
network_interface_name = "nic-pe-law"
}
}
}
9 changes: 9 additions & 0 deletions examples/deploy_network_isolation/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 68f61b4

Please sign in to comment.