diff --git a/frontend/api/api.ts b/frontend/api/api.ts index 667817ee..d495812a 100644 --- a/frontend/api/api.ts +++ b/frontend/api/api.ts @@ -6,8 +6,7 @@ import { } from "./types/types"; const apiUrl = import.meta.env.VITE_API_URL || "http://localhost:8000/"; -const middlewareURL = - import.meta.env.VITE_MIDDLEWARE_URL || "http://localhost:8000/"; +const middlewareURL = import.meta.env.MIDDLEWARE_API_URL || "http://localhost:8000/"; export const AlignImage = async ( args: AlignImageArgs, @@ -45,7 +44,7 @@ export const ImageToText = async ( labels: JSON.stringify(fieldNames), }); - const imageToTextURL = `${apiUrl}image_to_text/`; + const imageToTextURL = `${middlewareURL}/api/image_file_to_text/`; try { const response = await fetch(imageToTextURL, { method: "POST", diff --git a/ops/terraform/main.tf b/ops/terraform/main.tf index d5bea414..034dc484 100644 --- a/ops/terraform/main.tf +++ b/ops/terraform/main.tf @@ -24,7 +24,6 @@ module "networking" { # The DNS zone and DNS link are managed inside the networking module. postgres_server_id = module.database.postgres_server_id - } module "securitygroup" { @@ -130,14 +129,17 @@ module "ocr_autoscale" { module "database" { source = "./modules/database" env = local.environment + name = var.name resource_group_name = data.azurerm_resource_group.rg.name - subnet = module.networking.dbsubnet_id + db_subnet = module.networking.dbsubnet_id private_dns_zone_id = module.networking.private_dns_zone_id postgres_password = module.vault.postgres_password # Password from Vault to DB } module "vault" { source = "./modules/vault" + env = local.environment + name = var.name location = data.azurerm_resource_group.rg.location resource_group_name = data.azurerm_resource_group.rg.name env = local.environment diff --git a/ops/terraform/modules/database/main.tf b/ops/terraform/modules/database/main.tf index ce371058..eba5cbc4 100644 --- a/ops/terraform/modules/database/main.tf +++ b/ops/terraform/modules/database/main.tf @@ -2,7 +2,7 @@ # As a result we are using Azure Database for PostgreSQL Flexible Server # with granular control, flexibility and better cost optimization. resource "azurerm_postgresql_flexible_server" "postgres_flexible_server" { - name = "reportvisionpostgresql-flexible-server-${var.env}" + name = "${var.name}postgresql-fs-${var.env}" location = var.location resource_group_name = var.resource_group_name sku_name = var.postgres_sku_name @@ -12,14 +12,14 @@ resource "azurerm_postgresql_flexible_server" "postgres_flexible_server" { administrator_login = var.db_username administrator_password = var.postgres_password - delegated_subnet_id = var.subnet + delegated_subnet_id = var.db_subnet private_dns_zone_id = var.private_dns_zone_id # Disable Public Network Access public_network_access_enabled = false lifecycle { - prevent_destroy = true + prevent_destroy = false ignore_changes = [zone] } } diff --git a/ops/terraform/modules/database/variables.tf b/ops/terraform/modules/database/variables.tf index 6a81bd7f..583741fe 100644 --- a/ops/terraform/modules/database/variables.tf +++ b/ops/terraform/modules/database/variables.tf @@ -15,6 +15,11 @@ variable "location" { default = "eastus2" } +variable "name" { + type = string + description = "The name of the Project" +} + variable "resource_group_name" { type = string description = "The Azure Resource Group to deploy to" @@ -32,7 +37,7 @@ variable "postgres_sku_name" { default = "B_Standard_B1ms" } -variable "subnet" { +variable "db_subnet" { type = string description = "The subnet ID to associate with the PostgreSQL Flexible Server" } diff --git a/ops/terraform/modules/network/main.tf b/ops/terraform/modules/network/main.tf index 82f06af1..b3bd9069 100644 --- a/ops/terraform/modules/network/main.tf +++ b/ops/terraform/modules/network/main.tf @@ -110,4 +110,13 @@ resource "azurerm_private_endpoint" "psql_db_pivate_endpoint" { name = "dns-zone-group" private_dns_zone_ids = [azurerm_private_dns_zone.postgresql_dns_zone.id] } + depends_on = [var.postgres_server_id] } + +resource "azurerm_postgresql_flexible_server_firewall_rule" "app_service_firewall_rule" { + name = "allow-app-service" + server_id = var.postgres_server_id + start_ip_address = cidrhost(var.middlewaresubnetcidr, 0) # CIDR block start + end_ip_address = cidrhost(var.middlewaresubnetcidr, 255) # CIDR block end +} + diff --git a/ops/terraform/modules/network/variables.tf b/ops/terraform/modules/network/variables.tf index f8a8bce0..7a8a63e3 100644 --- a/ops/terraform/modules/network/variables.tf +++ b/ops/terraform/modules/network/variables.tf @@ -13,6 +13,4 @@ variable "location" { } variable "postgres_server_id" { - description = "The ID of the PostgreSQL server" - type = string } diff --git a/ops/terraform/modules/vault/main.tf b/ops/terraform/modules/vault/main.tf index 86afd7ba..37d0115f 100644 --- a/ops/terraform/modules/vault/main.tf +++ b/ops/terraform/modules/vault/main.tf @@ -1,10 +1,11 @@ resource "azurerm_key_vault" "this" { - name = "reportvisionvault-${var.env}" - location = var.location - resource_group_name = var.resource_group_name - sku_name = "standard" - tenant_id = data.azurerm_client_config.current.tenant_id - purge_protection_enabled = true + name = "${var.name}vault${var.env}" + location = var.location + resource_group_name = var.resource_group_name + sku_name = "standard" + tenant_id = data.azurerm_client_config.current.tenant_id + purge_protection_enabled = false + soft_delete_retention_days = 7 access_policy { tenant_id = data.azurerm_client_config.current.tenant_id @@ -32,7 +33,7 @@ resource "random_string" "postgres_password" { } resource "azurerm_key_vault_secret" "postgres_db_password" { - name = "reportvision-postgres-db-password" + name = "${var.name}postgresdb-pwd-${var.env}" value = random_string.postgres_password.result key_vault_id = azurerm_key_vault.this.id diff --git a/ops/terraform/modules/vault/variables.tf b/ops/terraform/modules/vault/variables.tf index 98d491dd..f2fe888a 100644 --- a/ops/terraform/modules/vault/variables.tf +++ b/ops/terraform/modules/vault/variables.tf @@ -1,5 +1,7 @@ variable "client_id" {} +variable "env" {} variable "location" {} +variable "name" {} variable "object_id" { type = string } diff --git a/ops/terraform/providers.tf b/ops/terraform/providers.tf index 8a7fb866..af5f3ead 100644 --- a/ops/terraform/providers.tf +++ b/ops/terraform/providers.tf @@ -19,11 +19,6 @@ terraform { } provider "azurerm" { - features { - key_vault { - purge_soft_delete_on_destroy = true - recover_soft_deleted_key_vaults = true - } - } + features {} }