Skip to content

Commit 5958bca

Browse files
committed
Commented-09-10-11-files
1 parent 0358458 commit 5958bca

File tree

2 files changed

+114
-226
lines changed

2 files changed

+114
-226
lines changed
Lines changed: 114 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
2-
31
trigger:
42
- master
53

64
pool:
75
vmImage: 'ubuntu-latest'
86

9-
10-
# Define Variables
7+
# Define Variables for Environments
118
variables:
129
- name: DEV_ENVIRONMENT
13-
value: dev
10+
value: dev
1411
- name: QA_ENVIRONMENT
15-
value: qa
16-
12+
value: qa
1713

18-
# Stage-1: Validate Stage
19-
## Step-1: Install Latest Terraform (Ideally not needed if we use default Agents)
20-
## Step-2: Validate Terraform Manifests
14+
# Stage-1: Terraform Validate Stage
15+
## Step-1: Publish Artifacts to Pipeline (Pipeline artifacts provide a way to share files between stages in a pipeline or between different pipelines. )
16+
## Step-2: Install Latest Terraform (0.13.5) (Ideally not needed if we use default Ubuntu Agents)
17+
## Step-3: Validate Terraform Manifests (terraform init, terraform validate)
2118

2219
stages:
23-
- stage: Validate
20+
- stage: TerraformValidate
2421
jobs:
25-
- job: ValidateJob
26-
continueOnError: false
27-
steps:
28-
- publish: terraform-manifests
29-
artifact: terraform-manifests-out
22+
- job: TerraformValidateJob
23+
continueOnError: false
24+
steps:
25+
- task: PublishPipelineArtifact@1
26+
displayName: Publish Artifacts
27+
inputs:
28+
targetPath: '$(System.DefaultWorkingDirectory)/terraform-manifests'
29+
artifact: 'terraform-manifests-out'
30+
publishLocation: 'pipeline'
3031
- task: TerraformInstaller@0
31-
displayName: Terraform Installer
32+
displayName: Terraform Install
3233
inputs:
3334
terraformVersion: 'latest'
3435
- task: TerraformCLI@0
@@ -37,9 +38,9 @@ stages:
3738
command: 'init'
3839
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
3940
backendType: 'azurerm'
40-
backendServiceArm: 'terraform-aks-azurerm-for-pipe3'
41-
backendAzureRmResourceGroupName: 'terraform-state-storage-rg2'
42-
backendAzureRmStorageAccountName: 'tfstatekalyan123'
41+
backendServiceArm: 'terraform-aks-azurerm-svc-con'
42+
backendAzureRmResourceGroupName: 'terraform-storage-rg'
43+
backendAzureRmStorageAccountName: 'terraformstatexlrwdrzs'
4344
backendAzureRmContainerName: 'tfstatefiles'
4445
backendAzureRmKey: 'aks-base.tfstate'
4546
allowTelemetryCollection: false
@@ -49,112 +50,107 @@ stages:
4950
command: 'validate'
5051
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
5152
allowTelemetryCollection: false
52-
53-
54-
5553

5654
# Stage-2: Deploy Stages for Dev & QA
5755
# Deployment-1: Deploy Dev AKS Cluster
58-
## Step-1: Download Secure File
59-
## Step-2: Terraform Initialize (State Storage to store in Azure Storage Account)
60-
## Step-3: Terraform Plan
61-
## Step-4: Terraform Apply
62-
- stage: DeployAKS
63-
jobs:
64-
- deployment: DeployDev
65-
pool:
66-
vmImage: 'ubuntu-latest'
67-
environment: $(DEV_ENVIRONMENT)
68-
strategy:
69-
# default deployment strategy
70-
runOnce:
71-
deploy:
72-
steps:
73-
- task: DownloadSecureFile@1
74-
displayName: Download SSH Key for Linux VMs
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-for-pipe3'
85-
backendAzureRmResourceGroupName: 'terraform-state-storage-rg2'
86-
backendAzureRmStorageAccountName: 'tfstatekalyan123'
87-
backendAzureRmContainerName: 'tfstatefiles'
88-
backendAzureRmKey: 'aks-$(DEV_ENVIRONMENT).tfstate'
89-
allowTelemetryCollection: false
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)
9061

91-
- task: TerraformCLI@0
92-
displayName: Terraform Plan
93-
inputs:
94-
command: 'plan'
95-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
96-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
97-
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(DEV_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
98-
allowTelemetryCollection: false
99-
100-
- task: TerraformCLI@0
101-
displayName: Terraform Apply
102-
inputs:
103-
command: 'apply'
104-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
105-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
106-
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(DEV_ENVIRONMENT)-$(Build.BuildId).out'
107-
allowTelemetryCollection: false
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
108106

109107
# Stage-2: Deploy Stages for Dev & QA
110108
# Deployment-2: Deploy QA AKS Cluster
111109
## Step-1: Download Secure File
112110
## Step-2: Terraform Initialize (State Storage to store in Azure Storage Account)
113111
## Step-3: Terraform Plan
114-
## Step-4: Terraform Apply
115-
116-
- deployment: DeployQA
117-
dependsOn: DeployDev
118-
pool:
119-
vmImage: 'ubuntu-latest'
120-
environment: $(QA_ENVIRONMENT)
121-
strategy:
122-
# default deployment strategy
123-
runOnce:
124-
deploy:
125-
steps:
126-
- task: DownloadSecureFile@1
127-
displayName: Download SSH Key for Linux VMs
128-
name: sshkey
129-
inputs:
130-
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
131-
- task: TerraformCLI@0
132-
displayName: Terraform Init
133-
inputs:
134-
command: 'init'
135-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
136-
backendType: 'azurerm'
137-
backendServiceArm: 'terraform-aks-azurerm-for-pipe3'
138-
backendAzureRmResourceGroupName: 'terraform-state-storage-rg2'
139-
backendAzureRmStorageAccountName: 'tfstatekalyan123'
140-
backendAzureRmContainerName: 'tfstatefiles'
141-
backendAzureRmKey: 'aks-$(QA_ENVIRONMENT).tfstate'
142-
allowTelemetryCollection: false
112+
## Step-4: Terraform Apply
143113

144-
- task: TerraformCLI@0
145-
displayName: Terraform Plan
146-
inputs:
147-
command: 'plan'
148-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
149-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
150-
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(QA_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
151-
allowTelemetryCollection: false
152-
153-
- task: TerraformCLI@0
154-
displayName: Terraform Apply
155-
inputs:
156-
command: 'apply'
157-
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
158-
environmentServiceName: 'terraform-aks-azurerm-for-pipe3'
159-
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
160-
allowTelemetryCollection: false
114+
- deployment: DeployQAAKSCluster
115+
dependsOn: DeployDevAKSCluster
116+
displayName: DeployQAAKSCluster
117+
pool:
118+
vmImage: 'ubuntu-latest'
119+
environment: $(QA_ENVIRONMENT)
120+
strategy:
121+
runOnce:
122+
deploy:
123+
steps:
124+
- task: DownloadSecureFile@1
125+
displayName: Download SSH Key
126+
name: sshkey
127+
inputs:
128+
secureFile: 'aks-terraform-devops-ssh-key-ububtu.pub'
129+
- task: TerraformCLI@0
130+
displayName: Terraform Init
131+
inputs:
132+
command: 'init'
133+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
134+
backendType: 'azurerm'
135+
backendServiceArm: 'terraform-aks-azurerm-svc-con'
136+
backendAzureRmResourceGroupName: 'terraform-storage-rg'
137+
backendAzureRmStorageAccountName: 'terraformstatexlrwdrzs'
138+
backendAzureRmContainerName: 'tfstatefiles'
139+
backendAzureRmKey: 'aks-$(QA_ENVIRONMENT).tfstate'
140+
allowTelemetryCollection: false
141+
- task: TerraformCLI@0
142+
displayName: Terraform Plan
143+
inputs:
144+
command: 'plan'
145+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
146+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
147+
commandOptions: '-var ssh_public_key=$(sshkey.secureFilePath) -var environment=$(QA_ENVIRONMENT) -out $(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
148+
allowTelemetryCollection: false
149+
- task: TerraformCLI@0
150+
displayName: Terraform Apply
151+
inputs:
152+
command: 'apply'
153+
workingDirectory: '$(Pipeline.Workspace)/terraform-manifests-out'
154+
environmentServiceName: 'terraform-aks-azurerm-svc-con'
155+
commandOptions: '$(Pipeline.Workspace)/terraform-manifests-out/$(QA_ENVIRONMENT)-$(Build.BuildId).out'
156+
allowTelemetryCollection: false

pipeline-backups/02-terraform-provision-aks-cluster-pipeline.yml

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)