-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.tf
150 lines (138 loc) · 6.7 KB
/
main.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
138
139
140
141
142
143
144
145
146
147
148
149
150
terraform {
required_version = ">= 1.3"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.43.0"
}
}
}
provider "azurerm" {
features {}
}
data "azurerm_client_config" "current" {
}
resource "random_string" "resource_prefix" {
length = 6
special = false
upper = false
numeric = false
}
resource "azurerm_resource_group" "rg" {
name = "${var.resource_prefix != "" ? var.resource_prefix : random_string.resource_prefix.result}${var.resource_group_name}"
location = var.location
tags = var.tags
}
module "log_analytics_workspace" {
source = "./modules/log_analytics"
name = "${var.resource_prefix != "" ? var.resource_prefix : random_string.resource_prefix.result}${var.log_analytics_workspace_name}"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
tags = var.tags
}
module "application_insights" {
source = "./modules/application_insights"
name = "${var.resource_prefix != "" ? var.resource_prefix : random_string.resource_prefix.result}${var.application_insights_name}"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
tags = var.tags
application_type = var.application_insights_application_type
workspace_id = module.log_analytics_workspace.id
}
module "virtual_network" {
source = "./modules/virtual_network"
resource_group_name = azurerm_resource_group.rg.name
vnet_name = "${var.resource_prefix != "" ? var.resource_prefix : random_string.resource_prefix.result}${var.vnet_name}"
location = var.location
address_space = var.vnet_address_space
tags = var.tags
log_analytics_workspace_id = module.log_analytics_workspace.id
log_analytics_retention_days = var.log_analytics_retention_days
subnets = [
{
name : var.aca_subnet_name
address_prefixes : var.aca_subnet_address_prefix
private_endpoint_network_policies_enabled : true
private_link_service_network_policies_enabled : false
},
{
name : var.private_endpoint_subnet_name
address_prefixes : var.private_endpoint_subnet_address_prefix
private_endpoint_network_policies_enabled : true
private_link_service_network_policies_enabled : false
}
]
}
module "blob_private_dns_zone" {
source = "./modules/private_dns_zone"
name = "privatelink.blob.core.windows.net"
resource_group_name = azurerm_resource_group.rg.name
virtual_networks_to_link = {
(module.virtual_network.name) = {
subscription_id = data.azurerm_client_config.current.subscription_id
resource_group_name = azurerm_resource_group.rg.name
}
}
}
module "blob_private_endpoint" {
source = "./modules/private_endpoint"
name = "${title(module.storage_account.name)}PrivateEndpoint"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
subnet_id = module.virtual_network.subnet_ids[var.private_endpoint_subnet_name]
tags = var.tags
private_connection_resource_id = module.storage_account.id
is_manual_connection = false
subresource_name = "blob"
private_dns_zone_group_name = "BlobPrivateDnsZoneGroup"
private_dns_zone_group_ids = [module.blob_private_dns_zone.id]
}
module "storage_account" {
source = "./modules/storage_account"
name = lower("${var.resource_prefix != "" ? var.resource_prefix : random_string.resource_prefix.result}${var.storage_account_name}")
location = var.location
resource_group_name = azurerm_resource_group.rg.name
tags = var.tags
account_kind = var.storage_account_kind
account_tier = var.storage_account_tier
replication_type = var.storage_account_replication_type
}
module "container_apps" {
source = "./modules/container_apps"
managed_environment_name = "${var.resource_prefix != "" ? var.resource_prefix : random_string.resource_prefix.result}${var.managed_environment_name}"
location = var.location
resource_group_name = azurerm_resource_group.rg.name
tags = var.tags
infrastructure_subnet_id = module.virtual_network.subnet_ids[var.aca_subnet_name]
instrumentation_key = module.application_insights.instrumentation_key
workspace_id = module.log_analytics_workspace.id
dapr_components = [{
name = var.dapr_name
component_type = var.dapr_component_type
version = var.dapr_version
ignore_errors = var.dapr_ignore_errors
init_timeout = var.dapr_init_timeout
secret = [
{
name = "storageaccountkey"
value = module.storage_account.primary_access_key
}
]
metadata: [
{
name = "accountName"
value = module.storage_account.name
},
{
name = "containerName"
value = var.container_name
},
{
name = "accountKey"
secret_name = "storageaccountkey"
}
]
scopes = var.dapr_scopes
}]
container_apps = var.container_apps
}