Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ resource "azurerm_function_app" "igss_businesslogic_function" {
}


resource "azurerm_storage_account" "igss_iotbackendfunction_sa" {
name = "iotbefuncsa01"
#################
# Backend Function
#################
resource "azurerm_storage_account" "igss_backend_function_sa" {
name = "igssbefuncsa01"
resource_group_name = "${azurerm_resource_group.igss_iot_backend_rg.name}"
location = "${azurerm_resource_group.igss_iot_backend_rg.location}"
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_app_service_plan" "igss_iotbackend_appplan" {
name = "igss-iot-backend-appplan"

resource "azurerm_app_service_plan" "igss_backend_appplan" {
name = "igss-backend-appplan"

location = "${azurerm_resource_group.igss_iot_backend_rg.location}"
resource_group_name = "${azurerm_resource_group.igss_iot_backend_rg.name}"
kind = "FunctionApp"
Expand All @@ -57,10 +62,15 @@ resource "azurerm_app_service_plan" "igss_iotbackend_appplan" {
}
}

resource "azurerm_function_app" "igss_iotbackend_function" {
name = "igss-iot-backend-function"

resource "azurerm_function_app" "igss_backend_function" {
name = "igss-backend-functions"
location = "${azurerm_resource_group.igss_iot_backend_rg.location}"
resource_group_name = "${azurerm_resource_group.igss_iot_backend_rg.name}"
app_service_plan_id = "${azurerm_app_service_plan.igss_iotbackend_appplan.id}"
storage_connection_string = "${azurerm_storage_account.igss_iotbackendfunction_sa.primary_connection_string}"
app_service_plan_id = "${azurerm_app_service_plan.igss_backend_appplan.id}"
storage_connection_string = "${azurerm_storage_account.igss_backend_function_sa.primary_connection_string}"
identity {
type = "SystemAssigned"
}

}
37 changes: 37 additions & 0 deletions iot-backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,40 @@ resource "azurerm_template_deployment" "igss_streamanalyitics_deployment" {
}
#Further configuration is done with powershell scripts in ./StreamAnalytics/...

##################
# Cosmos DB
##################

resource "random_integer" "ri" {
min = 10000
max = 99999
}

resource "azurerm_cosmosdb_account" "igss_cosmosdb" {
name = "igss-iot-cosmosdb-${random_integer.ri.result}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the random integer needed in the name?

location = "${azurerm_resource_group.igss_iot_backend_rg.location}"
resource_group_name = "${azurerm_resource_group.igss_iot_backend_rg.name}"
offer_type = "Standard"
kind = "MongoDB"

enable_automatic_failover = true

consistency_policy {
consistency_level = "BoundedStaleness"
max_interval_in_seconds = 10
max_staleness_prefix = 200
}

geo_location {
prefix = "igss-iot-cosmosdb-${random_integer.ri.result}-customid"
location = "${azurerm_resource_group.igss_iot_backend_rg.location}"
failover_priority = 0
}
}

resource "azurerm_key_vault_secret" "igss_cosmosdb_connectionstring" {
name = "igss-cosmosdb-connectionstring"
value = "${azurerm_cosmosdb_account.igss_cosmosdb.connection_strings[0]}"
key_vault_id = "${azurerm_key_vault.igss_keyvault.id}"
depends_on = ["azurerm_key_vault_access_policy.igss_keyvault_accesspolicy02"]
}
19 changes: 19 additions & 0 deletions security.tf
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,22 @@ resource "azurerm_key_vault_access_policy" "igss_keyvault_accesspolicy03" {
]

}

/*
resource "azurerm_key_vault_access_policy" "igss_keyvault_accesspolicy04" {
vault_name = "${azurerm_key_vault.igss_keyvault.name}"
resource_group_name = "${azurerm_key_vault.igss_keyvault.resource_group_name}"

tenant_id = "${data.azurerm_client_config.clientconfig_current.tenant_id}"
object_id = "${azurerm_function_app.igss_backend_function.identity.principal_id}"

key_permissions = [
"get"
]

secret_permissions = [
"get"
]
depends_on = ["azurerm_function_app.igss_backend_function"]
}
*/