Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Grazer Linuxtage - Azure Infrastructure as Code...

Grazer Linuxtage - Azure Infrastructure as Code Hands-on Workshop

Slides von meinem Workshop bei den "Grazer Linuxtage" 2025.

https://pretalx.linuxtage.at/glt25/talk/TSL7G8/

In diesem Workshop werden wir erkunden, wie man die Bereitstellung von Ressourcen auf Azure automatisieren kann. Infrastructure as Code ist unerlässlich, wenn man auf nachhaltige Cloud-Bereitstellungen setzen möchten. Wenn du lernen möchtest, wie man Tools wie Azure CLI und Terraform (Open-Source IaC Tool) verwendet, um die Bereitstellung von Ressourcen in Azure zu automatisieren, dann bist du hier genau richtig. Nicht sehr erfahren oder Anfänger:in? Kein Problem, wir werden zuerst die Konzepte in der Theorie durchgehen und dann gemeinsam die entsprechenden Befehle und Konfigurationen schreiben.

Inhalt:

Was ist die Azure CLI?
Verwendung der Azure CLI
Bereitstellung von Ressourcen auf Azure mit der Azure CLI
Was ist Terraform?
Wie schreibt man sein eigene Terraform-Konfiguration, worauf muss man achten?
Bereitstellung und Zerstörung von Ressourcen auf Azure mittels Terraform
Du benötigst nur einen Laptop mit einem installierten (aktualisierten) Browser deiner Wahl, Visual Studio Code und ein GitHub-Konto.

Patrick Koch

April 24, 2025
Tweet

More Decks by Patrick Koch

Other Decks in Programming

Transcript

  1. Content  GitHub Codespaces  Azure CLI  Terraform Source

    GitHub Codespaces icon: https://education.github.com/experiences/primer_codespaces, Azure Icon: Azure Public Service Icons V14, Ubuntu Icon: https://en.m.wikipedia.org/wiki/File:Logo-ubuntu_cof-orange-hex.svg, Terraform Icon: HashiCorp Brand Kit
  2. on-site / dev environment in the cloud user Terraform configuration

    in a GitHub Codespace Ubuntu virtual machine Source GitHub Codespaces icon: https://education.github.com/experiences/primer_codespaces, Azure Icons: Azure Public Service Icons V14, Ubuntu Icon: https://en.m.wikipedia.org/wiki/File:Logo-ubuntu_cof-orange-hex.svg, Terraform Icon: HashiCorp Brand Kit Goal
  3. Create a new GitHub repository  Arbitrary name  Add

    the ".devcontainer" directory from the GitHub repo below in your newly created GitHub repository  https://github.com/patkoch/azure_terraform_codespace
  4. Create a Terraform configuration for a Linux Virtual Machine Source

    GitHub Codespaces icon: https://education.github.com/experiences/primer_codespaces, Azure Icons: Azure Public Service Icons V14, Ubuntu Icon: https://en.m.wikipedia.org/wiki/File:Logo-ubuntu_cof-orange-hex.svg, Terraform Icon: HashiCorp Brand Kit
  5. terraform.tf terraform { required_providers { azurerm = { source =

    "hashicorp/azurerm" version = "~> 2.65" } } } https://github.com/patkoch/terraform-azure-virtual-machine-linux/blob/main/terraform.tf
  6. main.tf resource "azurerm_resource_group" "example" { name = "example-resources" location =

    "West Europe" } …. Change the name of the vm and the name of the resource group https://github.com/patkoch/terraform-azure-virtual-machine-linux/blob/main/main.tf
  7. variables.tf variable "virtual_machine_name" { type = string default = "glt-24"

    description = "Name of the virtual machine" } variable "virtual_machine_admin_username" { type = string default = "adminuser" description = "Admin user name" } ... https://github.com/patkoch/terraform-azure-virtual-machine-linux/blob/main/variables.tf
  8. Deploying the virtual machine  https://github.com/patkoch/terraform-azure-virtual-machine-linux  Create a RSA

    key pair ssh-keygen -t rsa -f id_rsa  terraform init  terraform fmt # format  terraform validate # validate  terraform plan –out tfplan # create an execution plan  terraform apply tfplan # deploy the resources
  9. Connect to the Ubuntu VM  chmod 600 id_rsa 

    ssh -i id_rsa adminuser@<public IP of the virtual machine>  ls –la  exit