Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions CHAP02/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
resource "azurerm_resource_group" "rg" {
name = "bookRg"
location = "West Europe"

tags = {
environment = "Terraform Azure"
}
}

resource "azurerm_virtual_network" "vnet" {
name = "book-vnet"
location = "West Europe"
address_space = ["10.0.0.0/16"]
resource_group_name = azurerm_resource_group.rg.name
}

resource "azurerm_subnet" "subnet" {
name = "book-subnet"
virtual_network_name = azurerm_virtual_network.vnet.name
resource_group_name = azurerm_resource_group.rg.name
address_prefixes = ["10.0.10.0/24"]
}

resource "azurerm_network_interface" "nic" {
name = "book-nic"
location = "West Europe"
resource_group_name = azurerm_resource_group.rg.name

ip_configuration {
name = "bookipconfig"
subnet_id = azurerm_subnet.subnet.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.pip.id
}
}

resource "azurerm_public_ip" "pip" {
name = "book-ip"
location = "West Europe"
resource_group_name = azurerm_resource_group.rg.name
# public_ip_address_allocation = ""
domain_name_label = "bookdevops"
allocation_method = "Dynamic"
}

resource "azurerm_storage_account" "stor" {
name = "bookstor"
location = "West Europe"
resource_group_name = azurerm_resource_group.rg.name
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_virtual_machine" "vm" {
name = "bookvm"
location = "West Europe"
resource_group_name = azurerm_resource_group.rg.name
vm_size = "Standard_DS1_v2"
network_interface_ids = [azurerm_network_interface.nic.id]

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}

storage_os_disk {
name = "book-osdisk"
managed_disk_type = "Standard_LRS"
caching = "ReadWrite"
create_option = "FromImage"
}

os_profile {
computer_name = "VMBOOK"
admin_username = "admin"
admin_password = "book123*"
}

os_profile_linux_config {
disable_password_authentication = false
}

boot_diagnostics {
enabled = true
storage_uri = azurerm_storage_account.stor.primary_blob_endpoint
}
}

3 changes: 3 additions & 0 deletions CHAP02/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "azurerm" {
features {}
}
8 changes: 8 additions & 0 deletions CHAP02/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_version = ">= 0.13"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
}
}
}