File tree Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,12 @@ jobs:
35
35
- name : " Terraform init"
36
36
run : |
37
37
pwd
38
- terraform init
38
+ terraform init -backend-config="${{ github.event.deployment_environment }}-backend-config="backend.config"
39
39
40
40
- name : Terraform Apply
41
41
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
43
44
44
45
- name : Terraform destroy plan
45
46
if : github.event.inputs.confirm == 'yes'
Original file line number Diff line number Diff line change
1
+ resource_group_name = "terraform-rg"
2
+ storage_account_name = "gharunnerbackend"
3
+ container_name = "tfstate-container"
4
+ key = "terraform.tfstate"
Original file line number Diff line number Diff line change 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
17
1
provider "azurerm" {
18
- features {
19
- resource_group {
20
- prevent_deletion_if_contains_resources = false
21
- }
22
- }
2
+ features {}
23
3
}
24
4
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"
29
8
}
30
9
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
+ }
31
17
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
+ }
You can’t perform that action at this time.
0 commit comments