From 563e5708372afaf1738e410e7a1516271755dc67 Mon Sep 17 00:00:00 2001 From: Sabrina <9669990+violetbrina@users.noreply.github.com> Date: Tue, 16 May 2023 11:32:56 +1000 Subject: [PATCH] FIX: storage accounts weren't unique. Added prefix. Fixed zone bug in flexible mysql db setup as well --- infra/azure/main.tf | 2 ++ infra/azure/modules/batch/main.tf | 4 ++-- infra/azure/modules/batch/variables.tf | 4 ++++ infra/azure/modules/ci/main.tf | 2 +- infra/azure/modules/ci/variables.tf | 4 ++++ infra/azure/modules/db/main.tf | 9 ++++++++- infra/azure/variables.tf | 4 ++++ 7 files changed, 25 insertions(+), 4 deletions(-) diff --git a/infra/azure/main.tf b/infra/azure/main.tf index d91b23e30a9..ec32ff7db28 100644 --- a/infra/azure/main.tf +++ b/infra/azure/main.tf @@ -94,6 +94,7 @@ module "batch" { batch_test_user_storage_account_name = var.batch_test_user_storage_account_name resource_group = data.azurerm_resource_group.rg container_registry_id = azurerm_container_registry.acr.id + storage_account_suffix = var.storage_account_suffix } module "global_config" { @@ -132,4 +133,5 @@ module "ci" { github_context = var.ci_config.github_context ci_and_deploy_github_oauth_token = var.ci_config.ci_and_deploy_github_oauth_token ci_test_repo_creator_github_oauth_token = var.ci_config.ci_test_repo_creator_github_oauth_token + storage_account_suffix = var.storage_account_suffix } diff --git a/infra/azure/modules/batch/main.tf b/infra/azure/modules/batch/main.tf index 47ca3a32a88..4f279d741d1 100644 --- a/infra/azure/modules/batch/main.tf +++ b/infra/azure/modules/batch/main.tf @@ -50,7 +50,7 @@ resource "kubernetes_secret" "batch_worker_ssh_public_key" { } resource "azurerm_storage_account" "batch" { - name = "${var.resource_group.name}batch" + name = "${var.resource_group.name}batch${var.storage_account_suffix}" resource_group_name = var.resource_group.name location = var.resource_group.location account_tier = "Standard" @@ -74,7 +74,7 @@ resource "azurerm_storage_container" "query" { } resource "azurerm_storage_account" "test" { - name = "${var.batch_test_user_storage_account_name}test" + name = "${var.batch_test_user_storage_account_name}test${var.storage_account_suffix}" resource_group_name = var.resource_group.name location = var.resource_group.location account_tier = "Standard" diff --git a/infra/azure/modules/batch/variables.tf b/infra/azure/modules/batch/variables.tf index 8138550ff15..81a9d7ef862 100644 --- a/infra/azure/modules/batch/variables.tf +++ b/infra/azure/modules/batch/variables.tf @@ -13,3 +13,7 @@ variable batch_test_user_storage_account_name { variable container_registry_id { type = string } + +variable storage_account_suffix { + type = string +} diff --git a/infra/azure/modules/ci/main.tf b/infra/azure/modules/ci/main.tf index 3b31d03a182..f3b1eaff1ef 100644 --- a/infra/azure/modules/ci/main.tf +++ b/infra/azure/modules/ci/main.tf @@ -1,5 +1,5 @@ resource "azurerm_storage_account" "ci" { - name = "${var.resource_group.name}ci" + name = "${var.resource_group.name}ci${var.storage_account_suffix}" resource_group_name = var.resource_group.name location = var.resource_group.location account_tier = "Standard" diff --git a/infra/azure/modules/ci/variables.tf b/infra/azure/modules/ci/variables.tf index 0cd8c85cf28..24c8fe95ec0 100644 --- a/infra/azure/modules/ci/variables.tf +++ b/infra/azure/modules/ci/variables.tf @@ -36,3 +36,7 @@ variable "deploy_steps" { variable "github_context" { type = string } + +variable "storage_account_suffix" { + type = string +} diff --git a/infra/azure/modules/db/main.tf b/infra/azure/modules/db/main.tf index 45f6c7ceb65..8d5faeb2c22 100644 --- a/infra/azure/modules/db/main.tf +++ b/infra/azure/modules/db/main.tf @@ -36,7 +36,14 @@ resource "azurerm_mysql_flexible_server" "db" { # Which availability zone (out of 1,2,3) that the database should be hosted # in. This should ideally match the zone that batch is in but we don't have # availability zones enabled in AKS. - zone = 1 + # Commented out due to the following error: + # │ Error: waiting for creation of Flexible Server: (Name "db-2138b3b3" / Resource Group "hail"): Code="AvailableZoneNotFound" Message="The availiabilityZone '1' is not found for subscription id '4453ab2e-2015-4bf0-adf2-7b2fa1f207e3'." + # │ + # │ with module.db.azurerm_mysql_flexible_server.db, + # │ on modules/db/main.tf line 22, in resource "azurerm_mysql_flexible_server" "db": + # │ 22: resource "azurerm_mysql_flexible_server" "db" { + # │ + # zone = 1 delegated_subnet_id = var.subnet_id private_dns_zone_id = azurerm_private_dns_zone.db.id diff --git a/infra/azure/variables.tf b/infra/azure/variables.tf index b4d1d967c5c..9d08f1cc6c6 100644 --- a/infra/azure/variables.tf +++ b/infra/azure/variables.tf @@ -59,3 +59,7 @@ variable oauth2_developer_redirect_uris { type = list(string) default = [] } + +variable storage_account_suffix { + type = string +}