Skip to content

Commit

Permalink
Merge pull request #29 from ai-cfia/28-as-a-devops-i-would-like-to-au…
Browse files Browse the repository at this point in the history
…tomate-azure-infrastructure-deployment-using-terraform

Issue #28: As a DevOps, I would like to automate Azure infrastructure deployment using Terraform
  • Loading branch information
SonOfLope authored Feb 7, 2024
2 parents 81b6cf1 + bb2dfbf commit 4fef77e
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 34 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/infra-ci-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Infra integration workflow

on:
pull_request:
types:
- opened
- closed
- synchronize

jobs:

markdown-check:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-markdown-check.yml@76-as-a-devops-i-would-like-to-fix-the-markdown-lint-workflow

yaml-check:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-yaml-check.yml@main

repo-standard:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-repo-standards-validation.yml@main
secrets: inherit

terraform-check:
uses:
ai-cfia/github-workflows/.github/workflows/workflow-terraform-check.yml@main
with:
config-file-path: '.tflint.hcl'
22 changes: 22 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}

plugin "azurerm" {
enabled = true
version = "0.25.1"
source = "github.com/terraform-linters/tflint-ruleset-azurerm"
}

plugin "aws" {
enabled = true
version = "0.29.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}

plugin "google" {
enabled = true
version = "0.26.0"
source = "github.com/terraform-linters/tflint-ruleset-google"
}
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Infrastructure Repository for ACIA-CFIA AI-Lab

This repository is dedicated to the infrastructure management of the ACIA-CFIA AI-Lab. It contains scripts, configurations, and documentation pertinent to infrastructure and DevOps practices within the lab, facilitating setup, deployment, and management across multiple cloud platforms including AWS, GCP, and Azure.
This repository is dedicated to the infrastructure management of the ACIA-CFIA
AI-Lab. It contains scripts, configurations, and documentation pertinent to
infrastructure and DevOps practices within the lab, facilitating setup,
deployment, and management across multiple cloud platforms including AWS, GCP,
and Azure.

## Contents:
## Contents

Cross-Cloud Setup Scripts: Automation scripts for seamless configuration across AWS, GCP, and Azure, covering project initiation, billing account association, artifact repository orchestration, and service account setup.
GitHub Repository Creation Guide: Detailed instructions for creating new repositories in alignment with ACIA-CFIA standards.
Getting Started:
Cross-Cloud Setup Scripts: Automation scripts for seamless configuration across
AWS, GCP, and Azure, covering project initiation, billing account association,
artifact repository orchestration, and service account setup. GitHub Repository
Creation Guide: Detailed instructions for creating new repositories in alignment
with ACIA-CFIA standards. Getting Started:

## Clone this repository

## Clone this repository.
1. Navigate to the desired script or documentation.
2. Follow the provided instructions.
3. Related Repositories:

Dev-Rel-Docs: Contains introductory files and documentation related to developer relations at ACIA-CFIA AI-Lab.
Dev-Rel-Docs: Contains introductory files and documentation related to developer
relations at ACIA-CFIA AI-Lab.
82 changes: 55 additions & 27 deletions apply-terraform.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,61 @@
---
trigger:
branches:
include:
- 3-create-a-kubernetes-cluster-for-azure-w-the-ingress-nginx
- main

pool:
vmImage: 'ubuntu-latest'
steps:
- task: TerraformTaskV1@0
displayName: Terra Init
inputs:
provider: 'azurerm'
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
backendServiceArm: 'CFSC-AiLabChatbot-Sub-SP'
backendAzureRmResourceGroupName: 'rg-ai-cfia-terraform-state'
backendAzureRmStorageAccountName: 'tfcfiastate'
backendAzureRmContainerName: 'infra-terraform-state'
backendAzureRmKey: 'tf/terraform.tfstate'
- task: TerraformTaskV1@0
displayName: Terra Plan
inputs:
provider: 'azurerm'
command: 'plan'
workingDirectory: $(System.DefaultWorkingDirectory)
environmentServiceNameAzureRM: 'CFSC-AiLabChatbot-Sub-SP'
- task: TerraformTaskV1@0
displayName: Terra Apply
inputs:
provider: 'azurerm'
command: 'apply'
workingDirectory: $(System.DefaultWorkingDirectory)
environmentServiceNameAzureRM: 'CFSC-AiLabChatbot-Sub-SP'

variables:
- group: terraform-backend-settings

stages:
- stage: InitAndPlan
displayName: 'Initialize and Plan'
jobs:
- job: TerraformInitPlan
displayName: 'Terraform Init and Plan'
steps:
- task: TerraformTaskV2@2
displayName: Terra Init
inputs:
provider: 'azurerm'
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
backendServiceArm: '$(serviceConnectionName)'
backendAzureRmResourceGroupName: '$(resourceGroupName)'
backendAzureRmStorageAccountName: '$(storageAccountName)'
backendAzureRmContainerName: '$(containerName)'
backendAzureRmKey: '$(stateKey)'

- task: TerraformTaskV1@0
displayName: Terra Plan
inputs:
provider: 'azurerm'
command: 'plan'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform'
environmentServiceNameAzureRM: '$(serviceConnectionName)'

- stage: Apply
displayName: 'Apply Terraform Plan'
dependsOn: InitAndPlan
condition: succeeded()
jobs:
- deployment: TerraformApply
displayName: 'Terraform Apply'
pool:
vmImage: 'ubuntu-latest'
environment: 'ProductionApproval'
strategy:
runOnce:
deploy:
steps:
- task: TerraformTaskV1@0
displayName: 'Terra Apply'
inputs:
provider: 'azurerm'
command: 'apply'
workingDirectory:
'$(System.DefaultWorkingDirectory)/terraform'
environmentServiceNameAzureRM: '$(serviceConnectionName)'

0 comments on commit 4fef77e

Please sign in to comment.