-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
107 lines (85 loc) · 2.78 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
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">=3.8"
}
}
backend "azurerm" {
resource_group_name = "OpenCohort21_IanBoorer_ProjectExercise"
storage_account_name = "tfstate10ibtf"
container_name = "tfstate"
key = "terraform.tfstate"
}
}
provider "azurerm" {
features {}
}
data "azurerm_resource_group" "main" {
name = "OpenCohort21_IanBoorer_ProjectExercise"
}
resource "azurerm_service_plan" "main" {
name = "${var.prefix}-terraformed-asp"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
os_type = "Linux"
sku_name = "B1"
}
resource "azurerm_linux_web_app" "main" {
name = "${var.prefix}-todoapp"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
service_plan_id = azurerm_service_plan.main.id
site_config {
application_stack {
docker_image = "${var.DOCKER_IMAGE}"
docker_image_tag = "latest"
}
}
app_settings = {
DOCKER_REGISTRY_SERVER_URL = "https://index.docker.io"
DOCKER_REGISTRY_SERVER_USERNAME = "${var.DOCKER_REGISTRY_SERVER_USERNAME}"
DOCKER_REGISTRY_SERVER_PASSWORD = "${var.DOCKER_REGISTRY_SERVER_PASSWORD}"
CLIENT_ID= "${var.CLIENT_ID}"
CLIENT_SECRET="${var.CLIENT_SECRET}"
GITHUB_OAUTH_URL="https://github.com/login/oauth/authorize"
REDIRECT_URI="https://${var.prefix}-todoapp.azurewebsites.net/login/callback"
CONNECTION_STRING=azurerm_cosmosdb_account.main.connection_strings[0]
DATABASE="todo_app"
COLLECTION="items"
SECRET_KEY="${var.SECRET_KEY}"
FLASK_APP="${var.FLASK_APP}"
FLASK_ENV="${var.FLASK_ENV}"
}
}
resource "azurerm_cosmosdb_account" "main" {
name = "${var.prefix}-mongodb-account"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
offer_type = "Standard"
kind = "MongoDB"
enable_automatic_failover = false
capabilities {
name = "EnableServerless"
}
capabilities {
name = "EnableMongo"
}
lifecycle {
prevent_destroy = true
}
consistency_policy {
consistency_level = "Session"
max_interval_in_seconds = 5
max_staleness_prefix = 100
}
geo_location {
location = "UK West"
failover_priority = 0
}
}
resource "azurerm_cosmosdb_mongo_database" "main" {
name = "${var.prefix}-todoapp-db"
resource_group_name = azurerm_cosmosdb_account.main.resource_group_name
account_name = azurerm_cosmosdb_account.main.name
}