generated from Azure/terraform-azurerm-avm-template
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmain.tf
More file actions
270 lines (250 loc) · 7.16 KB
/
main.tf
File metadata and controls
270 lines (250 loc) · 7.16 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
terraform {
required_version = ">= 1.9, < 2.0"
required_providers {
azapi = {
source = "azure/azapi"
version = "~> 2.0"
}
azurerm = {
source = "hashicorp/azurerm"
version = ">= 3.116, < 5.0"
}
http = {
source = "hashicorp/http"
version = "~> 3.4"
}
random = {
source = "hashicorp/random"
version = "~> 3.5"
}
}
}
provider "azurerm" {
features {
resource_group {
prevent_deletion_if_contains_resources = false
}
virtual_machine {
delete_os_disk_on_deletion = true
}
cognitive_account {
purge_soft_delete_on_destroy = true
}
}
}
locals {
location = "swedencentral"
}
data "azurerm_client_config" "current" {}
## Section to provide a random Azure region for the resource group
# This allows us to randomize the region for the resource group.
module "regions" {
source = "Azure/avm-utl-regions/azurerm"
version = "0.9.2"
}
# This allows us to randomize the region for the resource group.
resource "random_integer" "region_index" {
max = length(module.regions.regions) - 1
min = 0
}
## End of section to provide a random Azure region for the resource group
# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
version = "0.4.2"
}
# Get the deployer IP address to allow for public write to the key vault. This is to make sure the tests run.
# In practice your deployer machine will be on a private network and this will not be required.
data "http" "ip" {
url = "https://api.ipify.org/"
retry {
attempts = 5
max_delay_ms = 1000
min_delay_ms = 500
}
}
# Add a vnet in a separate resource group
resource "azurerm_resource_group" "vnet_rg" {
location = local.location
name = module.naming.resource_group.name_unique
}
#create a sample hub to mimic an existing network landing zone configuration
module "example_hub" {
source = "../../modules/example_hub_vnet"
deployer_ip_address = "${data.http.ip.response_body}/32"
location = local.location
resource_group_name = "default-example-${module.naming.resource_group.name_unique}"
vnet_definition = {
address_space = "10.10.0.0/24"
}
enable_telemetry = var.enable_telemetry
name_prefix = "${module.naming.resource_group.name_unique}-hub"
}
#create a BYO vnet and peer to the hub
module "vnet" {
source = "Azure/avm-res-network-virtualnetwork/azurerm"
version = "=0.16.0"
location = azurerm_resource_group.vnet_rg.location
parent_id = azurerm_resource_group.vnet_rg.id
address_space = ["192.168.0.0/20"] # has to be out of 192.168.0.0/16 currently. Other RFC1918 not supported for foundry capabilityHost injection.
dns_servers = {
dns_servers = [for key, value in module.example_hub.dns_resolver_inbound_ip_addresses : value]
}
name = module.naming.virtual_network.name_unique
peerings = {
peertovnet1 = {
name = "${module.naming.virtual_network_peering.name_unique}-vnet2-to-vnet1"
remote_virtual_network_resource_id = module.example_hub.virtual_network_resource_id
allow_forwarded_traffic = true
allow_gateway_transit = true
allow_virtual_network_access = true
create_reverse_peering = true
reverse_name = "${module.naming.virtual_network_peering.name_unique}-vnet1-to-vnet2"
reverse_allow_virtual_network_access = true
}
}
}
module "test" {
source = "../../"
location = local.location
resource_group_name = "ai-lz-rg-standalone-byo-vnet-${substr(module.naming.unique-seed, 0, 5)}"
vnet_definition = {
existing_byo_vnet = {
this_vnet = {
vnet_resource_id = module.vnet.resource_id
}
}
}
ai_foundry_definition = {
purge_on_destroy = true
ai_foundry = {
create_ai_agent_service = true
enable_diagnostic_settings = false
}
ai_model_deployments = {
"gpt-4o" = {
name = "gpt-4.1"
model = {
format = "OpenAI"
name = "gpt-4.1"
version = "2025-04-14"
}
scale = {
type = "GlobalStandard"
capacity = 1
}
}
}
ai_projects = {
project_1 = {
name = "project-1"
description = "Project 1 description"
display_name = "Project 1 Display Name"
create_project_connections = true
cosmos_db_connection = {
new_resource_map_key = "this"
}
ai_search_connection = {
new_resource_map_key = "this"
}
storage_account_connection = {
new_resource_map_key = "this"
}
}
}
ai_search_definition = {
this = {
}
}
cosmosdb_definition = {
this = {
consistency_level = "Session"
}
}
key_vault_definition = {
this = {
}
}
storage_account_definition = {
this = {
shared_access_key_enabled = true #configured for testing
endpoints = {
blob = {
type = "blob"
}
}
}
}
}
app_gateway_definition = {
backend_address_pools = {
example_pool = {
name = "example-backend-pool"
}
}
backend_http_settings = {
example_http_settings = {
name = "example-http-settings"
port = 80
protocol = "Http"
}
}
frontend_ports = {
example_frontend_port = {
name = "example-frontend-port"
port = 80
}
}
http_listeners = {
example_listener = {
name = "example-listener"
frontend_port_name = "example-frontend-port"
}
}
request_routing_rules = {
example_rule = {
name = "example-rule"
rule_type = "Basic"
http_listener_name = "example-listener"
backend_address_pool_name = "example-backend-pool"
backend_http_settings_name = "example-http-settings"
priority = 100
}
}
}
bastion_definition = {
}
container_app_environment_definition = {
enable_diagnostic_settings = false
}
enable_telemetry = var.enable_telemetry
flag_platform_landing_zone = false
genai_app_configuration_definition = {
enable_diagnostic_settings = false
}
genai_container_registry_definition = {
enable_diagnostic_settings = false
}
genai_cosmosdb_definition = {
consistency_level = "Session"
}
genai_key_vault_definition = {
#this is for AVM testing purposes only. Doing this as we don't have an easy for the test runner to be privately connected for testing.
public_network_access_enabled = true
network_acls = {
bypass = "AzureServices"
ip_rules = ["${data.http.ip.response_body}/32"]
}
}
genai_storage_account_definition = {
}
ks_ai_search_definition = {
enable_diagnostic_settings = false
}
private_dns_zones = {
existing_zones_resource_group_resource_id = module.example_hub.resource_group_resource_id
}
tags = {
SecurityControl = "Ignore"
}
}