From 27bccc460ddfa97b34e47ca9b7a4c095be341d15 Mon Sep 17 00:00:00 2001 From: Christian Fosli Date: Fri, 26 Jan 2024 21:23:24 +0100 Subject: [PATCH] fix(terraform): update tfstate storage account name, fix other recreate errors Add a '2' suffix after storage account name, due to "A storage account already exists with this name" error when trying to recreate infra in new tenant. Fix a couple of other deploy errors trying to recreate infra in new tenant. --- .github/workflows/terraform.yml | 2 +- terraform/api.tf | 3 ++- terraform/cleanup-job.tf | 2 ++ terraform/data.tf | 2 +- terraform/main.tf | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index 62de488..d3e2ac0 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -83,7 +83,7 @@ jobs: terraform -v terraform init --input=false \ -backend-config="resource_group_name=rg-snake-${{ env.TF_VAR_ENVIRONMENT }}" \ - -backend-config="storage_account_name=stsnake${{ env.TF_VAR_ENVIRONMENT }}" \ + -backend-config="storage_account_name=stsnake${{ env.TF_VAR_ENVIRONMENT }}2" \ -backend-config="key=${{ env.TF_VAR_ENVIRONMENT }}.terraform.tfstate" - name: Validate diff --git a/terraform/api.tf b/terraform/api.tf index 67d7b30..6df2f62 100644 --- a/terraform/api.tf +++ b/terraform/api.tf @@ -43,7 +43,8 @@ resource "azurerm_container_app" "highscoreApi" { target_port = 3000 traffic_weight { - percentage = 100 + percentage = 100 + latest_revision = true } # traffic weight will be adjusted during CI/CD as new revisions are published diff --git a/terraform/cleanup-job.tf b/terraform/cleanup-job.tf index 0281573..a789e16 100644 --- a/terraform/cleanup-job.tf +++ b/terraform/cleanup-job.tf @@ -23,6 +23,8 @@ resource "null_resource" "createCleanupJob" { --env-vars "DB_CONNSTR=secretref:db-connstr" EOF + interpreter = ["/bin/bash"] + # nonsensitive used on sensitive value to prevent all stdout from being hidden } } diff --git a/terraform/data.tf b/terraform/data.tf index 43b6784..c32c849 100644 --- a/terraform/data.tf +++ b/terraform/data.tf @@ -5,7 +5,7 @@ data "azurerm_resource_group" "rg" { } data "azurerm_storage_account" "st" { - name = "stsnake${var.ENVIRONMENT}" + name = "stsnake${var.ENVIRONMENT}2" resource_group_name = data.azurerm_resource_group.rg.name } diff --git a/terraform/main.tf b/terraform/main.tf index 32aa412..5b1acbd 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,7 +1,7 @@ terraform { backend "azurerm" { resource_group_name = "rg-snake-staging" - storage_account_name = "stsnakestaging" + storage_account_name = "stsnakestaging2" container_name = "tfstate" key = "staging.terraform.tfstate" use_oidc = true