-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathaadds.tf
137 lines (114 loc) · 4.32 KB
/
aadds.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Service Principal for Domain Controller Services published application
resource "azuread_service_principal" "aadds" {
application_id = var.domain_controller_services_id
}
# Microsoft.AAD Provider Registration
resource "azurerm_resource_provider_registration" "aadds" {
name = "Microsoft.AAD"
}
# AADDS DC Admin Group and User
resource "azuread_group" "dc_admins" {
display_name = "AAD DC Administrators"
description = "AADDS Administrators"
members = [azuread_user.dc_admin.object_id]
security_enabled = true
}
resource "random_password" "dc_admin" {
length = 64
}
resource "azuread_user" "dc_admin" {
user_principal_name = var.dc_admin_upn
display_name = "AADDS DC Administrator"
password = random_password.dc_admin.result
}
# Resource Group
resource "azurerm_resource_group" "aadds" {
name = "aadds-rg"
location = var.location
}
# Network Resources
resource "azurerm_virtual_network" "aadds" {
name = "aadds-vnet"
location = azurerm_resource_group.aadds.location
resource_group_name = azurerm_resource_group.aadds.name
address_space = ["10.0.0.0/16"]
}
resource "azurerm_subnet" "aadds" {
name = "aadds-snet"
resource_group_name = azurerm_resource_group.aadds.name
virtual_network_name = azurerm_virtual_network.aadds.name
address_prefixes = ["10.0.0.0/24"]
}
resource "azurerm_network_security_group" "aadds" {
name = "aadds-nsg"
location = azurerm_resource_group.aadds.location
resource_group_name = azurerm_resource_group.aadds.name
# Allow the Azure platform to monitor, manage, and update the managed domain
# See https://docs.microsoft.com/en-us/azure/active-directory-domain-services/alert-nsg#inbound-security-rules
security_rule {
name = "AllowRD"
priority = 201
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "3389"
source_address_prefix = "CorpNetSaw"
destination_address_prefix = "*"
}
security_rule {
name = "AllowPSRemoting"
priority = 301
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "5986"
source_address_prefix = "AzureActiveDirectoryDomainServices"
destination_address_prefix = "*"
}
# Restrict inbound LDAPS access to specific IP addresses to protect the managed domain from brute force attacks.
# See https://docs.microsoft.com/en-us/azure/active-directory-domain-services/alert-ldaps#resolution
# See https://docs.microsoft.com/en-us/azure/active-directory-domain-services/tutorial-configure-ldaps#lock-down-secure-ldap-access-over-the-internet
# security_rule {
# name = "AllowLDAPS"
# priority = 401
# direction = "Inbound"
# access = "Allow"
# protocol = "Tcp"
# source_port_range = "*"
# destination_port_range = "636"
# source_address_prefix = "<Authorized LDAPS IPs>"
# destination_address_prefix = "*"
# }
}
resource "azurerm_subnet_network_security_group_association" "aadds" {
subnet_id = azurerm_subnet.aadds.id
network_security_group_id = azurerm_network_security_group.aadds.id
}
# AADDS Managed Domain
resource "azurerm_active_directory_domain_service" "aadds" {
name = "aadds"
location = azurerm_resource_group.aadds.location
resource_group_name = azurerm_resource_group.aadds.name
domain_name = var.domain_name
sku = "Standard"
initial_replica_set {
subnet_id = azurerm_subnet.aadds.id
}
notifications {
additional_recipients = ["alice@example.com", "bob@example.com"]
notify_dc_admins = true
notify_global_admins = true
}
security {
sync_kerberos_passwords = true
sync_ntlm_passwords = true
sync_on_prem_passwords = true
}
depends_on = [
azuread_service_principal.aadds,
azurerm_resource_provider_registration.aadds,
azurerm_subnet_network_security_group_association.aadds,
]
}