Skip to content

Commit

Permalink
Added variable to specify whether to use local backend or azurerm bac…
Browse files Browse the repository at this point in the history
…kend.
  • Loading branch information
johncollinson2001 committed Sep 9, 2024
1 parent 2ae84f0 commit 1a00e23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
}' > infrastructure/backend.tf
- name: Terraform Init
run: terraform init
run: terraform init -backend-config="use_local_backend=true"
working-directory: infrastructure

- name: Terraform Validate
Expand Down
9 changes: 8 additions & 1 deletion infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ terraform {
}
}

backend "azurerm" {}
backend "local" {
path = "terraform.tfstate"
condition = var.use_local_backend
}

backend "azurerm" {
condition = !var.use_local_backend
}
}

provider "azurerm" {
Expand Down
6 changes: 6 additions & 0 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
variable "use_local_backend" {
description = "Set to true to use the local backend instead of azurerm"
type = bool
default = false
}

variable "vault_name" {
type = string
default = "myvault"
Expand Down

0 comments on commit 1a00e23

Please sign in to comment.