Skip to content

Instantly share code, notes, and snippets.

View JamesDLD's full-sized avatar

James Dumont Le Douarec JamesDLD

View GitHub Profile
#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
#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"
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
- 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:
- 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:
#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
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")
@JamesDLD
JamesDLD / pe-scenario1.ps1
Last active April 13, 2020 10:36
A Private Endpoint in the its Virtual Network Azure Subscription and Resource Group.
New-AzResourceGroupDeployment -Name "mystorageaccountname-pe1" -ResourceGroupName "myrgname" `
-TemplateUri https://raw.githubusercontent.com/JamesDLD/AzureRm-Template/master/Create-AzPrivateEnpoints/azuredeploy.json `
-tags "{""MyTagKey1"":""MyTagKey1Value"",""MyTagKey2"":""MyTagKey2Value""}""" `
-existingVirtualNetworkName "hub-vnet1" `
-existingVirtualNetworkSubnetName "endpoint-snet1" `
-existingResourceName "mystorageaccountname" `
-existingResourceType "Microsoft.Storage/storageAccounts" `
-groupIds @("blob")
@JamesDLD
JamesDLD / pe-scenario2.ps1
Created April 13, 2020 10:42
A Private Endpoint in the Hub and it's Resource in an Application Resource Group.
New-AzResourceGroupDeployment -Name "mystorageaccountname-pe1" -ResourceGroupName "MyHubRgName" `
-TemplateUri https://raw.githubusercontent.com/JamesDLD/AzureRm-Template/master/Create-AzPrivateEnpoints/azuredeploy.json `
-tags "{""MyTagKey1"":""MyTagKey1Value"",""MyTagKey2"":""MyTagKey2Value""}""" `
-existingVirtualNetworkName "hub-vnet1" `
-existingVirtualNetworkSubnetName "endpoint-snet1" `
-existingResourceSubscriptionId "xxxxx-xxxxx-xxxxx-xxxxx" `
-existingResourceResourceGroupName "MyAppRgName" `
-existingResourceName "mystorageaccountname" `
-existingResourceType "Microsoft.Storage/storageAccounts" `
-groupIds @("blob")
@JamesDLD
JamesDLD / pe-scenario3.ps1
Created April 13, 2020 10:46
A Private Endpoint with its Resource in the Application's Resource Group and its Ip address in a remote Virtual Network.
New-AzResourceGroupDeployment -Name "mystorageaccountname-pe1" -ResourceGroupName "MyAppRgName" `
-TemplateUri https://raw.githubusercontent.com/JamesDLD/AzureRm-Template/master/Create-AzPrivateEnpoints/azuredeploy.json `
-tags "{""MyTagKey1"":""MyTagKey1Value"",""MyTagKey2"":""MyTagKey2Value""}""" `
-existingVirtualNetworkResourceGroupName "MyHubRgName" `
-existingVirtualNetworkName "hub-vnet1" `
-existingVirtualNetworkSubnetName "endpoint-snet1" `
-existingResourceName "mystorageaccountname" `
-existingResourceType "Microsoft.Storage/storageAccounts" `
-groupIds @("blob")