-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
174 lines (141 loc) · 5.03 KB
/
main.tf
File metadata and controls
174 lines (141 loc) · 5.03 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
# Resource Group
resource "azurerm_resource_group" "rg" {
name = var.resource_group_name
location = var.location
# Output the resource group name
provisioner "local-exec" {
command = "echo Resource Group: ${self.name}"
}
}
# Storage Account
resource "azurerm_storage_account" "storage" {
name = var.storage_account_name
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "LRS"
depends_on = [azurerm_resource_group.rg]
# Output the storage account name
provisioner "local-exec" {
command = "echo Storage Account: ${self.name}"
}
}
# Blob Container for Input Files
resource "azurerm_storage_container" "input_container" {
name = "input"
storage_account_id = azurerm_storage_account.storage.id
container_access_type = "private"
depends_on = [azurerm_storage_account.storage]
# Output the container name
provisioner "local-exec" {
command = "echo Input Container: ${self.name}"
}
}
# Blob Container for Output Files
resource "azurerm_storage_container" "output_container" {
name = "output"
storage_account_id = azurerm_storage_account.storage.id
container_access_type = "private"
depends_on = [azurerm_storage_account.storage]
# Output the container name
provisioner "local-exec" {
command = "echo Output Container: ${self.name}"
}
}
# Linux Function App
resource "azurerm_linux_function_app" "function_app" {
name = var.function_app_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
service_plan_id = azurerm_service_plan.asp.id
storage_account_name = azurerm_storage_account.storage.name
storage_account_access_key = azurerm_storage_account.storage.primary_access_key
site_config {
# Other configurations can go here
}
depends_on = [azurerm_service_plan.asp]
provisioner "local-exec" {
command = "echo Function App: ${self.name}"
}
}
# Service Plan
resource "azurerm_service_plan" "asp" {
name = var.app_service_plan_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
os_type = "Linux"
sku_name = "Y1" # Consumption plan
depends_on = [azurerm_resource_group.rg]
# Output the service plan name
provisioner "local-exec" {
command = "echo Service Plan: ${self.name}"
}
}
# Application Insights
resource "azurerm_application_insights" "appinsights" {
name = var.app_insights_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
application_type = "web"
workspace_id = azurerm_log_analytics_workspace.loganalytics.id
depends_on = [azurerm_resource_group.rg]
provisioner "local-exec" {
command = "echo Application Insights: ${self.name}"
}
}
# Log Analytics Workspace
resource "azurerm_log_analytics_workspace" "loganalytics" {
name = var.log_analytics_workspace_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
sku = "PerGB2018"
depends_on = [azurerm_resource_group.rg]
# Output the log analytics workspace name
provisioner "local-exec" {
command = "echo Log Analytics Workspace: ${self.name}"
}
}
# Key Vault
resource "azurerm_key_vault" "keyvault" {
name = var.key_vault_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
tenant_id = data.azurerm_client_config.current.tenant_id
sku_name = "standard"
depends_on = [azurerm_resource_group.rg]
# Output the key vault name
provisioner "local-exec" {
command = "echo Key Vault: ${self.name}"
}
}
# Data source to get tenant ID
data "azurerm_client_config" "current" {}
# CosmosDB
resource "azurerm_cosmosdb_account" "cosmosdb" {
name = var.cosmosdb_account_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
consistency_policy {
consistency_level = "Session"
}
geo_location {
location = azurerm_resource_group.rg.location
failover_priority = 0
}
depends_on = [azurerm_resource_group.rg]
}
# Azure Form Recognizer (Document Intelligence)
resource "azurerm_cognitive_account" "form_recognizer" {
name = var.form_recognizer_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
kind = "FormRecognizer"
sku_name = "S0"
depends_on = [azurerm_resource_group.rg]
# Output the Form Recognizer name
provisioner "local-exec" {
command = "echo Form Recognizer: ${self.name}"
}
}