From ce94c97c88eb0f60f9456f191103b4c6987a4662 Mon Sep 17 00:00:00 2001 From: Raj Date: Tue, 6 Aug 2024 11:57:29 +0530 Subject: [PATCH] refactor: Update Azure deployment workflow for importing existing resources --- .github/workflows/azuredeploy.terraform.yml | 6 +----- infra/azuredeploy.tf | 9 ++------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/.github/workflows/azuredeploy.terraform.yml b/.github/workflows/azuredeploy.terraform.yml index 514816c..9d12ed9 100644 --- a/.github/workflows/azuredeploy.terraform.yml +++ b/.github/workflows/azuredeploy.terraform.yml @@ -31,12 +31,8 @@ jobs: working-directory: ./infra # Import existing resources - - name: Import Resource Group - run: terraform import azurerm_resource_group.example /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }} - working-directory: ./infra - - name: Import Static Web App - run: terraform import azurerm_static_web_app.example /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }}/providers/Microsoft.Web/staticSites/${{ vars.STATIC_WEB_APP_NAME }} + run: terraform import -var="resource_group_name=${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }}" azurerm_static_web_app.example /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/${{ secrets.HELLOWORLD_RESOURCE_GROUP_NAME }}/providers/Microsoft.Web/staticSites/${{ vars.STATIC_WEB_APP_NAME }} working-directory: ./infra # Apply Terraform diff --git a/infra/azuredeploy.tf b/infra/azuredeploy.tf index a02ca2e..851e67a 100644 --- a/infra/azuredeploy.tf +++ b/infra/azuredeploy.tf @@ -13,14 +13,9 @@ variable "resource_group_name" { type = string } -resource "azurerm_resource_group" "example" { - name = var.resource_group_name - location = "East Asia" -} - resource "azurerm_static_web_app" "example" { name = var.staticSites_name - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name + location = "East Asia" + resource_group_name = var.resource_group_name sku_tier = "Free" }