-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.tf
82 lines (77 loc) · 2.33 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
terraform {
backend "azurerm" {
resource_group_name = "SoftwirePilot_JosephFisher_ProjectExercise"
storage_account_name = "storageaccountjosfis"
container_name = "todoapp-container"
key = "TodoAppAccessKey"
}
}
provider "azurerm" {
features {}
}
data "azurerm_resource_group" "main" {
name = "SoftwirePilot_JosephFisher_ProjectExercise"
}
resource "azurerm_app_service_plan" "main" {
name = "${var.prefix}-asp-terraform"
location = var.location
resource_group_name = data.azurerm_resource_group.main.name
kind = "Linux"
reserved = true
sku {
tier = "Basic"
size = "B1"
}
}
resource "azurerm_cosmosdb_account" "main" {
name = "${var.prefix}-cosmosdb-account"
resource_group_name = data.azurerm_resource_group.main.name
location = var.location
offer_type = "Standard"
kind = "MongoDB"
capabilities {
name = "EnableServerless"
}
capabilities {
name = "EnableMongo"
}
consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 10
max_staleness_prefix = 200
}
geo_location {
location = data.azurerm_resource_group.main.location
failover_priority = 0
}
}
resource "azurerm_cosmosdb_mongo_database" "main" {
name = "${var.prefix}-cosmos-mongo-db"
resource_group_name = data.azurerm_resource_group.main.name
account_name = azurerm_cosmosdb_account.main.name
lifecycle {
prevent_destroy = true
}
}
resource "azurerm_app_service" "main" {
name = "${var.prefix}-terraform"
location = var.location
resource_group_name = data.azurerm_resource_group.main.name
app_service_plan_id = azurerm_app_service_plan.main.id
site_config {
app_command_line = ""
linux_fx_version = "DOCKER|joefish29/todo-app:latest"
}
app_settings = {
"DOCKER_REGISTRY_SERVER_URL" = "https://index.docker.io/v1"
"clientId" = var.clientId
"client_secret" = var.client_secret
"FLASK_APP" = "app"
"FLASK_ENV" = "developement"
"LOAD_DISABLED" = ""
"SECRET_KEY" = "real_key"
"LOG_LEVEL" = "DEBUG"
"Mongo_db" = "todoapp-cosmos-mongo-db"
"Mongo_Url" = "mongodb://${azurerm_cosmosdb_account.main.name}:${azurerm_cosmosdb_account.main.primary_key}@${azurerm_cosmosdb_account.main.name}.mongo.cosmos.azure.com:10255/DefaultDatabase?ssl=true&replicaSet=globaldb&retrywrites=false&maxIdleTimeMS=120000"
}
}