Slide 1

Slide 1 text

Generate & Transform IaC Code Bicep, Terraform, VS Code Thomas Hafermalz 30.09.2024 AZUG Meetup

Slide 2

Slide 2 text

THOMAS HAFERMALZ  Azure Solution Architect & Trainer (Zurich, )  Study: Industrial Environmental Informatics  Meetup: Azure Zurich User Group www.thomashafermalz.net www.linkedin.com/in/thomashafermalz

Slide 3

Slide 3 text

AGENDA ▪ Why IaC? ▪ Bicep & ARM ▪ Terraform ▪ Demo

Slide 4

Slide 4 text

WHY IAC

Slide 5

Slide 5 text

▪ Repeat your steps ▪Idempotence / declaration ▪Easier deployment across stages ▪Reproducibility / consistency ▪ Repositories ▪Traceability ▪Versioning ▪Teamwork BENEFITS OF IAC:

Slide 6

Slide 6 text

▪ Create from scratch ▪examples from documentation ▪Stackoverflow etc… ▪Where is MY usecase??? ▪ Existing templates in other language CHALLENGES (GET THE CODE)

Slide 7

Slide 7 text

BICEP

Slide 8

Slide 8 text

▪ Generate parameter files ▪ Import as Bicep code per resource ID ▪ Convert Bicep <-> ARM ▪Existing templates / snippets ▪ Helpful: Deployment Pane (experimental) ▪No bicepparam files atm BICEP OPTIONS

Slide 9

Slide 9 text

▪ VS Code ▪Extensions ▪Bicep ▪Azure CLI (scrapbooks) / Powershell ▪ Bicep CLI ▪Incl. in Azure CLI, additional needed for PowerShell WHAT DO I NEED?

Slide 10

Slide 10 text

BICEP DEMO

Slide 11

Slide 11 text

TERRAFORM

Slide 12

Slide 12 text

▪ Write code from existing infrastructure ▪Portal created ▪ No change / redeploy of resources (production) ▪State import BACKGROUND

Slide 13

Slide 13 text

▪ Import Block & config generate ▪Terraform v1.5 ▪ https://developer.hashicorp.com/terraform/language/import/generating-configuration ▪ Tf export tool («Terrafy») ▪Generate HCL incl. statefile ▪Various filter options for scope ▪Only Azure resources TERRAFORM OPTIONS 1

Slide 14

Slide 14 text

▪ Import from state ▪View on resource configuration (diagnostic tables) ▪ Azure portal export(soon) ▪ Other tools ▪Terraformer (GCP) and terracognita ▪Terraforming (AWS) TERRAFORM OPTIONS 2

Slide 15

Slide 15 text

▪ Features ▪Import complete RG with/without statefile ▪Interactive/automatic ▪Edit resource mapping ▪ Filters (query) ▪Single resource ▪Resource type (provider) ▪tags TERRAFORM EXPORT TOOL

Slide 16

Slide 16 text

▪ VS Code ▪Terraform runtime ▪Extensions ▪HashiCorp Terraform / Azure Terraform ▪Azure CLI (scrapbooks) / Powershell ▪ TF Export Tool ▪https://github.com/Azure/aztfexport/releases WHAT DO I NEED?

Slide 17

Slide 17 text

▪ Available set of modules supported by Microsoft ▪ For Bicep & Terraform ▪https://azure.github.io/Azure-Verified-Modules/ ▪'br/public:avm/res/network/virtual-network:' AZURE VERIFIED MODULES (AVM)

Slide 18

Slide 18 text

TERRAFORM DEMO

Slide 19

Slide 19 text

THANK YOU ☺