first commit

This commit is contained in:
yona committed 2026-04-20 14:14:56 +02:00
commit 82db27147e
3 files changed
+141

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
1. Install Azure CLI https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
2. Install Terraform https://developer.hashicorp.com/terraform
3. Make sure Azure CLI and Terraform can be accessed via PATH
4. Execute "az login" and login to your Azure account.
5. Adjust the files to your liking.
6. Try out the different commands: terraform init, plan, apply, destroy
+122
View File
@@ -0,0 +1,122 @@
resource "azurerm_resource_group" "res-0" {
location = "switzerlandnorth"
managed_by = "terraform-demo"
name = "rg-terraform-demo"
tags = {
Project = "b1clc-demo"
}
}
resource "azurerm_virtual_network" "res-9" {
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.res-0.location
name = "vm-demo-linux1-vnet"
resource_group_name = azurerm_resource_group.res-0.name
tags = {
Project = "b1clc-demo"
}
}
resource "azurerm_subnet" "res-10" {
address_prefixes = ["10.0.0.0/24"]
name = "default"
resource_group_name = azurerm_resource_group.res-0.name
virtual_network_name = azurerm_virtual_network.res-9.name
}
resource "azurerm_public_ip" "res-8" {
allocation_method = "Static"
ip_version = "IPv4"
location = azurerm_resource_group.res-0.location
name = "vm-demo-linux1-ip"
resource_group_name = azurerm_resource_group.res-0.name
sku = "Standard"
sku_tier = "Regional"
tags = {
Project = "b1clc-demo"
}
# Removed zones for Standard SKU compatibility
}
resource "azurerm_network_security_group" "res-5" {
location = azurerm_resource_group.res-0.location
name = "vm-demo-linux1-nsg"
resource_group_name = azurerm_resource_group.res-0.name
security_rule {
access = "Allow"
destination_address_prefix = "*"
destination_port_range = "22"
direction = "Inbound"
name = "SSH"
priority = 300
protocol = "Tcp"
source_address_prefix = "*"
source_port_range = "*"
}
security_rule {
access = "Allow"
destination_address_prefix = "*"
destination_port_range = "80"
direction = "Inbound"
name = "HTTP"
priority = 320
protocol = "Tcp"
source_address_prefix = "*"
source_port_range = "*"
}
tags = {
Project = "b1clc-demo"
}
}
resource "azurerm_network_interface" "res-3" {
location = azurerm_resource_group.res-0.location
name = "vm-demo-linux1823_z1"
resource_group_name = azurerm_resource_group.res-0.name
tags = {
Project = "b1clc-demo"
}
ip_configuration {
name = "ipconfig1"
primary = true
private_ip_address_version = "IPv4"
public_ip_address_id = azurerm_public_ip.res-8.id
subnet_id = azurerm_subnet.res-10.id
private_ip_address_allocation = "Dynamic"
}
}
resource "azurerm_network_interface_security_group_association" "res-4" {
network_interface_id = azurerm_network_interface.res-3.id
network_security_group_id = azurerm_network_security_group.res-5.id
}
resource "azurerm_linux_virtual_machine" "res-1" {
disable_password_authentication = false
admin_password = "test..123"
admin_username = "student"
computer_name = "vm-demo-linux1"
location = azurerm_resource_group.res-0.location
name = "vm-demo-linux1"
network_interface_ids = [azurerm_network_interface.res-3.id]
resource_group_name = azurerm_resource_group.res-0.name
size = "Standard_B2ats_v2"
zone = "1"
os_disk {
caching = "ReadWrite"
storage_account_type = "StandardSSD_LRS"
disk_size_gb = 30
}
source_image_reference {
offer = "ubuntu-24_04-lts"
publisher = "canonical"
sku = "server"
version = "latest"
}
tags = {
Project = "b1clc-demo"
}
}
+12
View File
@@ -0,0 +1,12 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "4.64.0"
}
}
}
provider "azurerm" {
# Configuration options
features {}
}