Skip to content

Commit 5842dc7

Browse files
fix: bicep storage account variables (#125)
* fix: bicep storage account variables * fmt
1 parent eb00c82 commit 5842dc7

8 files changed

Lines changed: 47 additions & 4 deletions

File tree

alz/azuredevops/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ module "azure_devops" {
9595
agent_pool_name = local.resource_names.version_control_system_agent_pool
9696
use_self_hosted_agents = var.use_self_hosted_agents
9797
create_branch_policies = var.create_branch_policies
98+
create_variable_group = var.iac_type == "terraform"
9899
}
99100

100101
module "file_manipulation" {

alz/azuredevops/pipelines/bicep-classic/templates/cd-template.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ stages:
1717
displayName: What If
1818
condition: eq($${{ parameters.skipWhatIf }}, false)
1919
variables:
20-
- group: ${variable_group_name}
2120
- name: parametersFileName
2221
value: parameters.json
2322

@@ -75,7 +74,6 @@ stages:
7574
dependsOn: whatif
7675
condition: not(or(failed(), canceled()))
7776
variables:
78-
- group: ${variable_group_name}
7977
- name: parametersFileName
8078
value: parameters.json
8179

alz/azuredevops/pipelines/bicep-classic/templates/ci-template.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ stages:
33
- stage: validate
44
displayName: Validation Bicep
55
variables:
6-
- group: ${variable_group_name}
76
- name: parametersFileName
87
value: parameters.json
98

alz/github/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ module "github" {
9696
default_runner_group_name = var.default_runner_group_name
9797
use_self_hosted_runners = var.use_self_hosted_runners
9898
create_branch_policies = var.create_branch_policies
99+
create_storage_account_variables = var.iac_type == "terraform"
99100
}
100101

101102
module "file_manipulation" {

modules/azure_devops/variable_group.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
resource "azuredevops_variable_group" "example" {
1+
resource "azuredevops_variable_group" "alz" {
2+
count = var.create_variable_group ? 1 : 0
23
project_id = local.project_id
34
name = var.variable_group_name
45
description = var.variable_group_name
@@ -19,3 +20,8 @@ resource "azuredevops_variable_group" "example" {
1920
value = var.backend_azure_storage_account_container_name
2021
}
2122
}
23+
24+
moved {
25+
from = "azuredevops_variable_group.example"
26+
to = "azuredevops_variable_group.alz[0]"
27+
}

modules/azure_devops/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,13 @@ variable "create_branch_policies" {
288288
EOT
289289
type = bool
290290
}
291+
292+
variable "create_variable_group" {
293+
description = <<-EOT
294+
**(Required)** Whether to create an Azure Pipelines variable group for shared configuration.
295+
296+
When true, creates a variable group containing backend and subscription details
297+
used across multiple pipelines.
298+
EOT
299+
type = bool
300+
}

modules/github/action_variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,37 @@ resource "github_actions_variable" "azure_tenant_id" {
1919
}
2020

2121
resource "github_actions_variable" "backend_azure_resource_group_name" {
22+
count = var.create_storage_account_variables ? 1 : 0
2223
repository = github_repository.alz.name
2324
variable_name = "BACKEND_AZURE_RESOURCE_GROUP_NAME"
2425
value = var.backend_azure_resource_group_name
2526
}
2627

2728
resource "github_actions_variable" "backend_azure_storage_account_name" {
29+
count = var.create_storage_account_variables ? 1 : 0
2830
repository = github_repository.alz.name
2931
variable_name = "BACKEND_AZURE_STORAGE_ACCOUNT_NAME"
3032
value = var.backend_azure_storage_account_name
3133
}
3234

3335
resource "github_actions_variable" "backend_azure_storage_account_container_name" {
36+
count = var.create_storage_account_variables ? 1 : 0
3437
repository = github_repository.alz.name
3538
variable_name = "BACKEND_AZURE_STORAGE_ACCOUNT_CONTAINER_NAME"
3639
value = var.backend_azure_storage_account_container_name
3740
}
41+
42+
moved {
43+
from = "github_actions_variable.backend_azure_resource_group_name"
44+
to = "github_actions_variable.backend_azure_resource_group_name[0]"
45+
}
46+
47+
moved {
48+
from = "github_actions_variable.backend_azure_storage_account_name"
49+
to = "github_actions_variable.backend_azure_storage_account_name[0]"
50+
}
51+
52+
moved {
53+
from = "github_actions_variable.backend_azure_storage_account_container_name"
54+
to = "github_actions_variable.backend_azure_storage_account_container_name[0]"
55+
}

modules/github/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,13 @@ variable "create_branch_policies" {
270270
EOT
271271
type = bool
272272
}
273+
274+
variable "create_storage_account_variables" {
275+
description = <<-EOT
276+
**(Required)** Whether to create GitHub Actions variables for Azure storage account details.
277+
278+
When true: Creates repository-level variables for backend storage configuration
279+
When false: Assumes variables are managed externally
280+
EOT
281+
type = bool
282+
}

0 commit comments

Comments
 (0)