Skip to content

Instantly share code, notes, and snippets.

View JamesDLD's full-sized avatar

James Dumont Le Douarec JamesDLD

View GitHub Profile
import json
import requests
import datetime
import hashlib
import hmac
import base64
#Retrieve your Log Analytics Workspace ID from your Key Vault Databricks Secret Scope
wks_id = dbutils.secrets.get(scope = "keyvault_scope", key = "wks-id-logaw1")
#Set the terraform backend
terraform {
backend "local" {} #Using a local backend just for the demo, the reco is to use a remote backend, see : https://jamesdld.github.io/terraform/Best-Practice/BestPractice-1/
}
#Set the Provider
provider "azurerm" {
tenant_id = var.tenant_id
subscription_id = var.subscription_id
client_id = var.client_id
- stage: Deliver
dependsOn: Deploy
jobs:
# track deployments on the environment
- deployment: Terraform_Destroy
displayName: Terraform Destroy - Script ok, now deleting the resources
pool:
vmImage: $(vmImageName)
environment: "Terraform_Destroy"
strategy:
- stage: Deploy
dependsOn: Build
jobs:
# track deployments on the environment
- deployment: Terraform_Apply
displayName: Terraform Apply - Resources creation
pool:
vmImage: $(vmImageName)
environment: "Terraform_Apply"
strategy:
stages:
- stage: Build
jobs:
- job: Terraform_Plan
displayName: Terraform Plan - Publish a package if Infrastructure changes are identified
continueOnError: false
pool:
vmImage: $(vmImageName)
steps:
- task: DownloadSecureFile@1
#Multi-stage YAML pipeline demo.
name: $(BuildDefinitionName).$(DayOfYear)$(Rev:.r)
variables:
- name: terraform_version
value: "0.12.13"
- name: vmImageName
value: "ubuntu-latest"
- name: backend_main_secret_file_id1 # secret id located in your Azure DevOps library, file used by the following cmdlet Terraform init, plan, apply and destroy
value: "backend-main-jdld-1.json"
#Multi-stage YAML pipeline demo.
name: $(BuildDefinitionName).$(DayOfYear)$(Rev:.r)
variables:
- group: terraform_binary # variable group containing Terraform information like the Terraform version (like terraform_version)
- name: vmImageName
value: 'ubuntu-latest'
- name: backend_main_secret_file_id1 # secret file used by the following cmdlet Terraform init, plan, apply and destroy
value: 'backend-main-jdld-1.json'
- name: ArtifactName