Skip to content

Commit ef8d1d2

Browse files
committed
Second Commit - Dev AKS Provision via terraform
1 parent 7c61476 commit ef8d1d2

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

01-terraform-provision-aks-cluster-pipeline.yml

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ trigger:
44
pool:
55
vmImage: 'ubuntu-latest'
66

7+
# Define Variables for Environments
8+
variables:
9+
- name: DEV_ENVIRONMENT
10+
value: dev
11+
- name: QA_ENVIRONMENT
12+
value: qa
13+
714
# Stage-1: Terraform Validate Stage
815
## Step-1: Publish Artifacts to Pipeline (Pipeline artifacts provide a way to share files between stages in a pipeline or between different pipelines. )
916
## Step-2: Install Latest Terraform (0.13.5) (Ideally not needed if we use default Ubuntu Agents)
@@ -42,4 +49,57 @@ stages:
4249
inputs:
4350
command: 'validate'
4451
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
45-
allowTelemetryCollection: false
52+
allowTelemetryCollection: false
53+
54+
# Stage-2: Deploy Stages for Dev & QA
55+
# Deployment-1: Deploy Dev AKS Cluster
56+
## Step-1: Define Variables for environments
57+
## Step-2: Download SSH Secure File
58+
## Step-3: Terraform Initialize (State Storage to store in Azure Storage Account for Dev AKS Cluster)
59+
## Step-4: Terraform Plan (Create Plan)
60+
## Step-5: Terraform Apply (Use the plan created in previous step)
61+
62+
- stage: DeployAKSClusters
63+
jobs:
64+
- deployment: DeployDevAKSCluster
65+
displayName: DeployDevAKSCluster
66+
pool:
67+
vmImage: 'ubuntu-latest'
68+
environment: $(DEV_ENVIRONMENT)
69+
strategy:
70+
runOnce:
71+
deploy:
72+
steps:
73+
- task: DownloadSecureFile@1
74+
displayName: Download SSH Key
75+
name: sshkey
76+
inputs:
77+
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
78+
- task: TerraformCLI@0
79+
displayName: Terraform Init
80+
inputs:
81+
command: 'init'
82+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
83+
backendType: 'azurerm'
84+
backendServiceArm: 'terraform-aks-azurerm-svc-con'
85+
backendAzureRmResourceGroupName: 'terraform-storage-rg'
86+
backendAzureRmStorageAccountName: 'terraformstatexlrwdrzs'
87+
backendAzureRmContainerName: 'tfstatefiles'
88+
backendAzureRmKey: 'aks-$(DEV_ENVIRONMENT).tfstate'
89+
allowTelemetryCollection: false
90+
- task: TerraformCLI@0
91+
displayName: Terraform Plan
92+
inputs:
93+
command: 'plan'
94+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
95+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
96+
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(DEV_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
97+
allowTelemetryCollection: false
98+
- task: TerraformCLI@0
99+
displayName: Terraform Apply
100+
inputs:
101+
command: 'apply'
102+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
103+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
104+
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
105+
allowTelemetryCollection: false

0 commit comments

Comments
 (0)