Skip to content

Commit bc84fa2

Browse files
committed
Merged PR 3: Pass environment as a parameter
Pass environment as a parameter
2 parents da57846 + 98e957b commit bc84fa2

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

.azuredevops/deploy-infrastructure.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ trigger: none
33
pool:
44
vmImage: "ubuntu-latest"
55

6+
parameters:
7+
- name: environment
8+
type: string
9+
default: "dev"
10+
values:
11+
- "dev"
12+
- "stg"
13+
- "prd"
14+
615
variables:
716
serviceConnection: "example-federated-sc"
817

@@ -20,29 +29,29 @@ jobs:
2029
inputs:
2130
provider: "azurerm"
2231
command: "init"
23-
workingDirectory: "$(System.DefaultWorkingDirectory)/ops"
24-
backendServiceArm: $(serviceConnection)
25-
backendAzureRmResourceGroupName: "terraform-rg"
26-
backendAzureRmStorageAccountName: "generaltfstatesta"
2732
backendAzureRmContainerName: "af-tf-state"
2833
backendAzureRmKey: "terraform.tfstate"
34+
backendAzureRmResourceGroupName: "terraform-rg"
35+
backendAzureRmStorageAccountName: "generaltfstatesta"
36+
backendServiceArm: $(serviceConnection)
37+
workingDirectory: "$(System.DefaultWorkingDirectory)/ops"
2938

3039
- task: TerraformTaskV4@4
3140
name: terraformPlan
3241
displayName: "Create Terraform Plan"
3342
inputs:
34-
provider: "azurerm"
3543
command: "plan"
36-
commandOptions: "-out main.tfplan"
44+
commandOptions: "-out main.tfplan -var env=${{ parameters.environment }}"
3745
environmentServiceNameAzureRM: $(serviceConnection)
46+
provider: "azurerm"
3847
workingDirectory: "$(System.DefaultWorkingDirectory)/ops"
3948

4049
- task: TerraformTaskV4@4
4150
displayName: "Apply Terraform Plan"
4251
condition: eq(variables['terraformPlan.changesPresent'], 'true')
4352
inputs:
44-
provider: "azurerm"
4553
command: "apply"
46-
workingDirectory: "$(System.DefaultWorkingDirectory)/ops"
54+
commandOptions: "main.tfplan -var env=${{ parameters.environment }}"
4755
environmentServiceNameAzureRM: $(serviceConnection)
48-
commandOptions: "main.tfplan"
56+
provider: "azurerm"
57+
workingDirectory: "$(System.DefaultWorkingDirectory)/ops"

ops/terraform.tfvars

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
function_version = "~4"
22
python_version = "3.11"
33
region = "westeurope"
4-
env = "dev"

0 commit comments

Comments
 (0)