-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
131 lines (106 loc) · 3.64 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
terraform{
required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
random = {
source = "hashicorp/random"
version = "3.0.1"
}
}
backend "remote" {
organization = "gunkut_dev"
workspaces {
name = "ItemTrader-APIDriven"
}
}
}
provider "azurerm" {
version = "2.5.0"
features {}
}
variable "SQL_DB_PASS" {
type = string
description = "Azure SQL Server Password"
}
variable "SQL_DB_USER" {
type = string
description = "Azure SQL Server User"
}
variable "SQL_SERVER_NAME" {
type = string
description = "Azure SQL Server Name"
}
variable "APP_INSIGHTS_INS_KEY" {
type = string
description = "Application Insights Instrumentation Key"
}
variable "AUTH_SERVER_HOST_NAME" {
type = string
description = "Authserver host name"
}
resource "azurerm_resource_group" "gunkut_dev" {
name = "itemtrader-tf"
location = "westus2"
}
resource "azurerm_sql_server" "gunkut_dev" {
name = var.SQL_SERVER_NAME
resource_group_name = azurerm_resource_group.gunkut_dev.name
location = azurerm_resource_group.gunkut_dev.location
version = "12.0"
administrator_login = var.SQL_DB_USER
administrator_login_password = var.SQL_DB_PASS
}
resource "azurerm_sql_database" "gunkut_dev" {
name = "ItemTraderDB"
resource_group_name = azurerm_resource_group.gunkut_dev.name
location = azurerm_resource_group.gunkut_dev.location
server_name = azurerm_sql_server.gunkut_dev.name
}
resource "azurerm_app_service_plan" "gunkut_dev" {
name = "itemtrader-appserviceplan"
location = azurerm_resource_group.gunkut_dev.location
resource_group_name = azurerm_resource_group.gunkut_dev.name
sku {
tier = "Free"
size = "F0"
}
}
resource "azurerm_app_service" "auth_server" {
name = "itemtrader-authserver"
location = azurerm_resource_group.gunkut_dev.location
resource_group_name = azurerm_resource_group.gunkut_dev.name
app_service_plan_id = azurerm_app_service_plan.gunkut_dev.id
connection_string {
name = "DefaultConnection"
type = "sqlserver"
value = "Server=${azurerm_sql_server.gunkut_dev.fully_qualified_domain_name};Database=${azurerm_sql_database.gunkut_dev.name};uid=${var.SQL_DB_USER};pwd=${var.SQL_DB_PASS}"
}
}
resource "azurerm_app_service" "itemtrader_api" {
name = "itemtrader-appservice"
location = azurerm_resource_group.gunkut_dev.location
resource_group_name = azurerm_resource_group.gunkut_dev.name
app_service_plan_id = azurerm_app_service_plan.gunkut_dev.id
app_settings = {
"AuthServer:Authority" = var.AUTH_SERVER_HOST_NAME
"ApplicationInsights:InstrumentationKey" = var.APP_INSIGHTS_INS_KEY
}
connection_string {
name = "DefaultConnection"
type = "sqlserver"
value = "Server=${azurerm_sql_server.gunkut_dev.fully_qualified_domain_name};Database=${azurerm_sql_database.gunkut_dev.name};uid=${var.SQL_DB_USER};pwd=${var.SQL_DB_PASS}"
}
}
output "app_service_name_itemtrader_api" {
value = "${azurerm_app_service.itemtrader_api.name}"
}
output "app_service_default_hostname_itemtrader_api" {
value = "https://${azurerm_app_service.itemtrader_api.default_site_hostname}"
}
output "app_service_name_auth_server" {
value = "${azurerm_app_service.auth_server.name}"
}
output "app_service_default_hostname_auth_server" {
value = "https://${azurerm_app_service.auth_server.default_site_hostname}"
}