Skip to content

Commit 5e10384

Browse files
committed
chore: update backend var
1 parent edbee9b commit 5e10384

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

.github/workflows/deploy_azure_infra.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ jobs:
3535
- name: "Terraform init"
3636
run : |
3737
pwd
38-
terraform init
38+
terraform init -backend-config="${{ github.event.deployment_environment }}-backend-config="backend.config"
3939
4040
- name: Terraform Apply
4141
if: github.event_name == 'push'
42-
run: terraform apply -auto-approve tfplan
42+
run: terraform apply -var-file=${{ github.event.deployment_environment }}.tfvars \
43+
-auto-approve tfplan
4344

4445
- name: Terraform destroy plan
4546
if: github.event.inputs.confirm == 'yes'

create-azure-infra/dev-backend.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
resource_group_name = "terraform-rg"
2+
storage_account_name = "gharunnerbackend"
3+
container_name = "tfstate-container"
4+
key = "terraform.tfstate"

create-azure-infra/provider.tf

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,22 @@
1-
terraform {
2-
required_providers {
3-
azurerm = {
4-
source = "hashicorp/azurerm"
5-
version = "4.12.0"
6-
}
7-
}
8-
backend "azurerm" {
9-
resource_group_name = "terraform-backend-rg"
10-
storage_account_name = azurerm_storage_account.gha_runner_sa.name
11-
container_name = azurerm_storage_container.tfstate_container.name
12-
key = "${var.project}-${var.env}-terraform.tfstate"
13-
}
14-
}
15-
16-
# Provider Configuration
171
provider "azurerm" {
18-
features {
19-
resource_group {
20-
prevent_deletion_if_contains_resources = false
21-
}
22-
}
2+
features {}
233
}
244

25-
resource "azurerm_storage_container" "tfstate_container" {
26-
name = "${var.project}-${var.env}-tfstate-container"
27-
storage_account_id = azurerm_storage_account.gha_runner_sa.id
28-
container_access_type = "private"
5+
resource "azurerm_resource_group" "example" {
6+
name = "example-rg"
7+
location = "East US"
298
}
309

10+
resource "azurerm_storage_account" "example" {
11+
name = "examplestorageacct" # Unique name
12+
resource_group_name = azurerm_resource_group.example.name
13+
location = azurerm_resource_group.example.location
14+
account_tier = "Standard"
15+
account_replication_type = "LRS"
16+
}
3117

32-
data "azurerm_client_config" "current" {}
18+
resource "azurerm_storage_container" "example" {
19+
name = "tfstate"
20+
storage_account_name = azurerm_storage_account.example.name
21+
container_access_type = "private"
22+
}

0 commit comments

Comments
 (0)