Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev PR #58

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
17 changes: 15 additions & 2 deletions terraform/application/app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "azurerm_linux_web_app" "this" {
use_32_bit_worker = false
always_on = true
application_stack {
python_version = "3.8"
python_version = "3.9"
}
app_command_line = "gunicorn icenet_app.app:app"
}
Expand All @@ -32,7 +32,8 @@ resource "azurerm_linux_web_app" "this" {
"ICENET_AUTH_LIST" = "/data/auth_list.json"
"ICENET_DATA_LOCATION" = "/data"
# "ENABLE_ORYX_BUILD" = "true"
# "SCM_DO_BUILD_DURING_DEPLOYMENT" = "true"
"SCM_DO_BUILD_DURING_DEPLOYMENT" = "true"
"DOCKER_ENABLE_CI" = "true"
}

storage_account {
Expand All @@ -44,6 +45,18 @@ resource "azurerm_linux_web_app" "this" {
mount_path = "/data"
}

logs {
application_logs {
file_system_level = "Information"
}
http_logs {
file_system {
retention_in_days = 7
retention_in_mb = 100
}
}
}

tags = local.tags
}

Expand Down
2 changes: 1 addition & 1 deletion terraform/backend.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ terraform {
}
azurerm = {
source = "hashicorp/azurerm"
version = "=3.59.0"
version = "=3.90.0"
}
null = {
source = "hashicorp/null"
Expand Down
35 changes: 12 additions & 23 deletions terraform/forecast_processor/functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ resource "azurerm_linux_function_app" "this" {
# enabled which mounts over the contents of the container.
# https://github.com/Azure/azure-functions-docker/issues/642
"WEBSITES_ENABLE_APP_SERVICE_STORAGE" = "false"
# Use an SAS Token with Blob read/list access
"AZURE_STORAGE_SAS_TOKEN" = var.storage_sas_token
# Use a service principal with blob read/list access (use either SAS token or service principal)
#"AZURE_CLIENT_ID" = var.service_principal_client_id
#"AZURE_CLIENT_SECRET" = var.service_principal_secret_val
#"AZURE_TENANT_ID" = var.tenant_id
#"AZURE_SUBSCRIPTION_ID" = var.subscription_id
}
identity {
type = "SystemAssigned"
Expand All @@ -140,29 +147,11 @@ resource "azurerm_linux_function_app" "this" {
}
}

resource "azurerm_role_definition" "app_data_read" {
description = "Allows for read access to Azure Storage blob containers and data"
name = "${local.app_name}-role-read-forecast-data"
scope = var.data_storage_account.id

permissions {
actions = [
"Microsoft.Storage/storageAccounts/blobServices/containers/read",
"Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey/action",
]
data_actions = [
"Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read",
]
not_actions = []
not_data_actions = []
}
}

resource "azurerm_role_assignment" "app_data_read_assoc" {
scope = var.data_storage_account.id
role_definition_id = azurerm_role_definition.app_data_read.role_definition_resource_id
principal_id = azurerm_linux_function_app.this.identity.0.principal_id
}
#resource "azurerm_role_assignment" "storage_blob_data_reader_assoc" {
# scope = var.data_storage_account.id
# role_definition_name = "Storage Blob Data Reader"
# principal_id = azurerm_linux_function_app.this.identity.0.principal_id
#}

#resource "azurerm_private_endpoint" "event_proc_endpoint" {
# name = "pvt-${var.project_name}-event-processing"
Expand Down
26 changes: 26 additions & 0 deletions terraform/forecast_processor/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ variable "default_tags" {
default = {}
}

variable "subscription_id" {
description = "Which Azure subscription to build in"
type = string
}
variable "tenant_id" {
description = "Which Azure tenant to build in"
type = string
}
variable "storage_sas_token" {
description = "Blob storage SAS token"
type = string
sensitive = true
}
variable "service_principal_client_id" {
description = "The special client/app ID, generated service principal for read/list blob storage access"
type = string
default = null
sensitive = true
}
variable "service_principal_secret_val" {
description = "Secret value of above service principal"
type = string
default = null
sensitive = true
}

# Local variables
locals {
tags = merge(
Expand Down
5 changes: 5 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ module "forecast_processor" {
notification_email = var.notification_email
sendfrom_email = var.sendfrom_email
dns_zone = module.network.dns_zone
storage_sas_token = var.storage_sas_token
service_principal_client_id = var.service_principal_client_id
service_principal_secret_val = var.service_principal_secret_val
tenant_id = var.tenant_id
subscription_id = var.subscription_id
}

module "web" {
Expand Down
17 changes: 17 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ variable "tenant_id" {
description = "Which Azure tenant to build in"
type = string
}
variable "storage_sas_token" {
description = "Blob storage SAS token"
type = string
sensitive = true
}
variable "service_principal_client_id" {
description = "The special client/app ID, generated service principal for read/list blob storage access"
type = string
default = null
sensitive = true
}
variable "service_principal_secret_val" {
description = "Secret value of above service principal"
type = string
default = null
sensitive = true
}

# These have sensible defaults
variable "domain_name" {
Expand Down