-
Notifications
You must be signed in to change notification settings - Fork 29
/
storage_account.tf
97 lines (78 loc) · 3.75 KB
/
storage_account.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
# Copyright (c) 2021 Microsoft
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Storage Account with VNET binding and Private Endpoint for Blob and File
resource "azurerm_storage_account" "aml_sa" {
name = "${var.prefix}sa${random_string.postfix.result}"
location = azurerm_resource_group.aml_rg.location
resource_group_name = azurerm_resource_group.aml_rg.name
account_tier = "Standard"
account_replication_type = "LRS"
}
# Virtual Network & Firewall configuration
resource "azurerm_storage_account_network_rules" "firewall_rules" {
resource_group_name = azurerm_resource_group.aml_rg.name
storage_account_name = azurerm_storage_account.aml_sa.name
default_action = "Deny"
ip_rules = []
virtual_network_subnet_ids = [azurerm_subnet.aml_subnet.id, azurerm_subnet.compute_subnet.id, azurerm_subnet.aks_subnet.id]
bypass = ["AzureServices"]
# Set network policies after Workspace has been created (will create File Share Datastore properly)
depends_on = [azurerm_machine_learning_workspace.aml_ws]
}
# DNS Zones
resource "azurerm_private_dns_zone" "sa_zone_blob" {
name = "privatelink.blob.core.windows.net"
resource_group_name = azurerm_resource_group.aml_rg.name
}
resource "azurerm_private_dns_zone" "sa_zone_file" {
name = "privatelink.file.core.windows.net"
resource_group_name = azurerm_resource_group.aml_rg.name
}
# Linking of DNS zones to Virtual Network
resource "azurerm_private_dns_zone_virtual_network_link" "sa_zone_blob_link" {
name = "${random_string.postfix.result}_link_blob"
resource_group_name = azurerm_resource_group.aml_rg.name
private_dns_zone_name = azurerm_private_dns_zone.sa_zone_blob.name
virtual_network_id = azurerm_virtual_network.aml_vnet.id
}
resource "azurerm_private_dns_zone_virtual_network_link" "sa_zone_file_link" {
name = "${random_string.postfix.result}_link_file"
resource_group_name = azurerm_resource_group.aml_rg.name
private_dns_zone_name = azurerm_private_dns_zone.sa_zone_file.name
virtual_network_id = azurerm_virtual_network.aml_vnet.id
}
# Private Endpoint configuration
resource "azurerm_private_endpoint" "sa_pe_blob" {
name = "${var.prefix}-sa-pe-blob-${random_string.postfix.result}"
location = azurerm_resource_group.aml_rg.location
resource_group_name = azurerm_resource_group.aml_rg.name
subnet_id = azurerm_subnet.aml_subnet.id
private_service_connection {
name = "${var.prefix}-sa-psc-blob-${random_string.postfix.result}"
private_connection_resource_id = azurerm_storage_account.aml_sa.id
subresource_names = ["blob"]
is_manual_connection = false
}
private_dns_zone_group {
name = "private-dns-zone-group-blob"
private_dns_zone_ids = [azurerm_private_dns_zone.sa_zone_blob.id]
}
}
resource "azurerm_private_endpoint" "sa_pe_file" {
name = "${var.prefix}-sa-pe-file-${random_string.postfix.result}"
location = azurerm_resource_group.aml_rg.location
resource_group_name = azurerm_resource_group.aml_rg.name
subnet_id = azurerm_subnet.aml_subnet.id
private_service_connection {
name = "${var.prefix}-sa-psc-file-${random_string.postfix.result}"
private_connection_resource_id = azurerm_storage_account.aml_sa.id
subresource_names = ["file"]
is_manual_connection = false
}
private_dns_zone_group {
name = "private-dns-zone-group-file"
private_dns_zone_ids = [azurerm_private_dns_zone.sa_zone_file.id]
}
}