Skip to content
Merged
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
29 changes: 23 additions & 6 deletions terraform-infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ resource "azurerm_resource_group" "rg" {
command = "echo Resource Group: ${self.name}"
}
}

# Storage Account
resource "azurerm_storage_account" "storage" {
name = var.storage_account_name
Expand Down Expand Up @@ -52,14 +53,30 @@ resource "azurerm_storage_container" "output_container" {
}
}

# Storage Account
resource "azurerm_storage_account" "runtime" {
name = var.storage_account_name_runtime
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "LRS"

depends_on = [azurerm_resource_group.rg]

# Output the storage account name
provisioner "local-exec" {
command = "echo Storage Account: ${self.name}"
}
}

# Linux Function App
resource "azurerm_linux_function_app" "function_app" {
name = var.function_app_name
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
service_plan_id = azurerm_service_plan.asp.id
storage_account_name = azurerm_storage_account.storage.name
storage_account_access_key = azurerm_storage_account.storage.primary_access_key
storage_account_name = azurerm_storage_account.runtime.name
storage_account_access_key = azurerm_storage_account.runtime.primary_access_key

identity {
type = "SystemAssigned"
Expand All @@ -78,27 +95,27 @@ resource "azurerm_linux_function_app" "function_app" {

# Assign Storage Blob Data Contributor role
resource "azurerm_role_assignment" "blob_data_contributor" {
scope = azurerm_storage_account.storage.id
scope = azurerm_storage_account.runtime.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = azurerm_linux_function_app.function_app.identity[0].principal_id


depends_on = [
azurerm_linux_function_app.function_app,
azurerm_storage_account.storage
azurerm_storage_account.runtime
]

}

# Assign Storage File Data SMB Share Contributor role
resource "azurerm_role_assignment" "file_data_smb_share_contributor" {
scope = azurerm_storage_account.storage.id
scope = azurerm_storage_account.runtime.id
role_definition_name = "Storage File Data SMB Share Contributor"
principal_id = azurerm_linux_function_app.function_app.identity[0].principal_id

depends_on = [
azurerm_linux_function_app.function_app,
azurerm_storage_account.storage
azurerm_storage_account.runtime
]
}

Expand Down
17 changes: 9 additions & 8 deletions terraform-infrastructure/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ subscription_id = "" # "your-subscription_id"
resource_group_name = "RG-PDFs-Processing-DocIntelligence" # "your-resource-group-name"
location = "West US" # "your-location"
# Storage Account
storage_account_name = "storageaccountbrownpdf" # "your-storage-account-name"
storage_account_name = "storageaccountbrownpdfx3" # "your-storage-account-name"
storage_account_name_runtime = "runtimestoragebrownx3" # "your-runtime-storage-account-name"
# Function App
function_app_name = "fapdfbrown" # "your-function-app-name"
function_app_name = "fapdfbrownx3" # "your-function-app-name"
# App Service Plan
app_service_plan_name = "asppdfbrown" # "your-app-service-plan-name"
app_service_plan_name = "asppdfbrownx3" # "your-app-service-plan-name"
# Application Insights
app_insights_name = "apppdfbrown" # "your-app-insights-name"
app_insights_name = "apppdfbrownx3" # "your-app-insights-name"
# Log Analytics Workspace
log_analytics_workspace_name = "logwspdfbrown" # "your-log-analytics-workspace-name"
log_analytics_workspace_name = "logwspdfbrownx3" # "your-log-analytics-workspace-name"
# Key Vault
key_vault_name = "kvpdfrbrown" # "your-key-vault-name"
key_vault_name = "kvpdfrbrownx3" # "your-key-vault-name"
# CosmosDB
cosmosdb_account_name = "cosmospdfbrown" # "your-cosmosdb-account-name"
cosmosdb_account_name = "cosmospdfbrownx3" # "your-cosmosdb-account-name"
# Form Recognizer -> Document Intelligence
form_recognizer_name = "docintelligenceacct01" # "your-document-intelligence-name"
form_recognizer_name = "docintelligenceacct01x3" # "your-document-intelligence-name"
5 changes: 5 additions & 0 deletions terraform-infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ variable "storage_account_name" {
type = string
}

variable "storage_account_name_runtime" {
description = "The name of the storage account runtime (Function App Storage)"
type = string
}

variable "function_app_name" {
description = "The name of the Linux Function App."
type = string
Expand Down