From b2fa1bebc15e14db76fa5226e0d2a71df1c7dec4 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Mon, 13 Jul 2026 15:20:54 +0300 Subject: [PATCH 01/13] Define Network Module. Add Network to main.tf --- .gitignore | 44 +++++++++++++++++ backend.tf | 0 main.tf | 37 +++++++++++++++ modules/network/main.tf | 49 +++++++++++++++++++ modules/network/outputs.tf | 0 modules/network/variables.tf | 91 ++++++++++++++++++++++++++++++++++++ outputs.tf | 0 variables.tf | 91 ++++++++++++++++++++++++++++++++++++ 8 files changed, 312 insertions(+) create mode 100644 .gitignore create mode 100644 backend.tf create mode 100644 main.tf create mode 100644 modules/network/main.tf create mode 100644 modules/network/outputs.tf create mode 100644 modules/network/variables.tf create mode 100644 outputs.tf create mode 100644 variables.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78e7733 --- /dev/null +++ b/.gitignore @@ -0,0 +1,44 @@ +# Local .terraform directories +.terraform/ + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log +crash.*.log + +# Exclude all .tfvars files, which are likely to contain sensitive data, such as +# password, private keys, and other secrets. These should not be part of version +# control as they are data points which are potentially sensitive and subject +# to change depending on the environment. +*.tfvars +*.tfvars.json + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Ignore transient lock info files created by terraform apply +.terraform.tfstate.lock.info + +# Include override files you do wish to add to version control using negated pattern +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* + +# Ignore CLI configuration files +.terraformrc +terraform.rc + +# Optional: ignore graph output files generated by `terraform graph` +# *.dot + +# Optional: ignore plan files saved before destroying Terraform configuration +# Uncomment the line below if you want to ignore planout files. +# planout \ No newline at end of file diff --git a/backend.tf b/backend.tf new file mode 100644 index 0000000..e69de29 diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..7ec33a6 --- /dev/null +++ b/main.tf @@ -0,0 +1,37 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "4.80.0" + } + random = { + source = "hashicorp/random" + version = "3.9.0" + } + } +} + +provider "azurerm" { + features { + + } +} +resource "random_string" "suffix" { + length = 4 + upper = false + special = false +} +module "network" { + source = "./modules/network" + prefix = var.prefix + resource_group_name = var.resource_group_name + resource_group_location = var.resource_group_location + network_name = var.network_name + v_net_address_prefix = var.v_net_address_prefix + subnet_name = var.subnet_name + subnet_address_prefix = var.subnet_address_prefix + pip_name = var.pip_name + dns_label = "${var.dns_label}-${random_string.suffix.result}" + network_SG_name = var.network_SG_name + security_rules = var.security_rules +} \ No newline at end of file diff --git a/modules/network/main.tf b/modules/network/main.tf new file mode 100644 index 0000000..af500d4 --- /dev/null +++ b/modules/network/main.tf @@ -0,0 +1,49 @@ +resource "azurerm_resource_group" "main" { + name = var.resource_group_name + location = var.resource_group_location +} + + +resource "azurerm_virtual_network" "main" { + name = var.network_name + address_space = ["10.0.0.0/16"] + location = azurerm_resource_group.main.location + resource_group_name = azurerm_resource_group.main.name +} + +resource "azurerm_subnet" "internal" { + name = var.subnet_name + resource_group_name = azurerm_resource_group.main.name + virtual_network_name = azurerm_virtual_network.main.name + address_prefixes = ["10.0.0.0/24"] +} + +resource "azurerm_public_ip" "mainIP" { + name = var.pip_name + resource_group_name = azurerm_resource_group.main.name + location = azurerm_resource_group.main.location + allocation_method = "Static" + sku = "Standard" + domain_name_label = var.dns_label +} + +resource "azurerm_network_security_group" "main" { + name = var.network_SG_name + location = azurerm_resource_group.main.location + resource_group_name = azurerm_resource_group.main.name + + dynamic "security_rule" { + for_each = var.security_rules + content { + name = security_rule.value.name + priority = security_rule.value.priority + direction = security_rule.value.direction + access = security_rule.value.access + protocol = security_rule.value.protocol + source_port_range = security_rule.value.source_port_range + destination_port_range = security_rule.value.destination_port_range + source_address_prefix = security_rule.value.source_address_prefix + destination_address_prefix = security_rule.value.destination_address_prefix + } + } +} \ No newline at end of file diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/network/variables.tf b/modules/network/variables.tf new file mode 100644 index 0000000..e4aa285 --- /dev/null +++ b/modules/network/variables.tf @@ -0,0 +1,91 @@ +variable "prefix" { + type = string + default = "myapp" +} + +variable "resource_group_name" { + description = "Name of the resource group" + type = string +} + +variable "resource_group_location" { + description = "Location of the resource group" + type = string +} + +variable "network_name" { + description = "Name of the virtual network" + type = string + default = "vnet" +} +variable "v_net_address_prefix" { + description = "Virtual network address prefix" + type = list(string) + default = ["10.0.0.0/16"] +} +variable "subnet_name" { + description = "Name of the subnet" + type = string + default = "default" +} + +variable "subnet_address_prefix" { + description = "Subnet address prefix" + type = list(string) + default = ["10.0.0.0/24"] +} +variable "pip_name" { + description = "Name of the puplic ip resource" + type = string + default = "linuxboxpip" +} +variable "dns_label" { + description = "DNS for service" + type = string + default = "matetask" +} +variable "network_SG_name" { + description = "Name of Network Security Group" + type = string + default = "defaultnsg" +} + +variable "security_rules" { + description = "List of security rules for the network security group" + type = list(object({ + name = string + priority = number + direction = string + access = string + protocol = string + source_port_range = string + destination_port_range = string + source_address_prefix = string + destination_address_prefix = string + })) + default = [ + { + name = "SSH" + priority = 100 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "22" + source_address_prefix = "*" + destination_address_prefix = "*" + }, + { + name = "HTTP" + priority = 200 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "80" + source_address_prefix = "*" + destination_address_prefix = "*" + } + ] +} + diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/variables.tf b/variables.tf new file mode 100644 index 0000000..2acd3ce --- /dev/null +++ b/variables.tf @@ -0,0 +1,91 @@ +variable "prefix" { + type = string + default = "myapp" +} + +variable "resource_group_name" { + description = "Name of the resource group" + type = string +} + +variable "resource_group_location" { + description = "Location of the resource group" + type = string +} + +variable "network_name" { + description = "Name of the virtual network" + type = string + default = "vnet" +} +variable "v_net_address_prefix" { + description = "Virtual network address prefix" + type = list(string) + default = ["10.0.0.0/16"] +} +variable "subnet_name" { + description = "Name of the subnet" + type = string + default = "default" +} + +variable "subnet_address_prefix" { + description = "Subnet address prefix" + type = list(string) + default = ["10.0.0.0/24"] +} +variable "pip_name" { + description = "Name of the puplic ip resource" + type = string + default = "linuxboxpip" +} +variable "dns_label" { + description = "DNS for service" + type = string + default = "matetask" +} +variable "network_SG_name" { + description = "Name of Network Security Group" + type = string + default = "defaultnsg" +} + +variable "security_rules" { + description = "List of security rules for the network security group" + type = list(object({ + name = string + priority = number + direction = string + access = string + protocol = string + source_port_range = string + destination_port_range = string + source_address_prefix = string + destination_address_prefix = string + })) + default = [ + { + name = "SSH" + priority = 100 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "22" + source_address_prefix = "*" + destination_address_prefix = "*" + }, + { + name = "HTTP" + priority = 200 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "80" + source_address_prefix = "*" + destination_address_prefix = "*" + } + ] +} + From ae196064635c37e4c7eab968602b6386be97a5c5 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Mon, 13 Jul 2026 16:12:47 +0300 Subject: [PATCH 02/13] outputs to Network module --- modules/network/outputs.tf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf index e69de29..e9588ee 100644 --- a/modules/network/outputs.tf +++ b/modules/network/outputs.tf @@ -0,0 +1,9 @@ +output "Virtal_network_id" { + value = azurerm_virtual_network.main.id +} +output "Public_IP" { + value = azurerm_public_ip.mainIP.ip_address +} +output "Pulibc Domain"{ + value = azurerm_public_ip.mainIP.domain_name_label +} \ No newline at end of file From 0bd191d9777ae0b7771fd5cd724ee11b90bec2d5 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Mon, 13 Jul 2026 16:51:32 +0300 Subject: [PATCH 03/13] Change variables names for readability Add outputs to Network Module --- main.tf | 10 +++++----- modules/network/outputs.tf | 2 +- variables.tf | 25 +++++++++++++++---------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/main.tf b/main.tf index 7ec33a6..69fcd82 100644 --- a/main.tf +++ b/main.tf @@ -25,13 +25,13 @@ module "network" { source = "./modules/network" prefix = var.prefix resource_group_name = var.resource_group_name - resource_group_location = var.resource_group_location - network_name = var.network_name - v_net_address_prefix = var.v_net_address_prefix + resource_group_location = var.location + network_name = var.virtual_network_name + v_net_address_prefix = var.vnet_address_prefix subnet_name = var.subnet_name subnet_address_prefix = var.subnet_address_prefix - pip_name = var.pip_name + pip_name = var.public_ip_address_name dns_label = "${var.dns_label}-${random_string.suffix.result}" - network_SG_name = var.network_SG_name + network_SG_name = var.network_security_group_name security_rules = var.security_rules } \ No newline at end of file diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf index e9588ee..e99d302 100644 --- a/modules/network/outputs.tf +++ b/modules/network/outputs.tf @@ -4,6 +4,6 @@ output "Virtal_network_id" { output "Public_IP" { value = azurerm_public_ip.mainIP.ip_address } -output "Pulibc Domain"{ +output "Public_domain" { value = azurerm_public_ip.mainIP.domain_name_label } \ No newline at end of file diff --git a/variables.tf b/variables.tf index 2acd3ce..a1d5f4c 100644 --- a/variables.tf +++ b/variables.tf @@ -1,24 +1,27 @@ -variable "prefix" { - type = string - default = "myapp" -} - +# COMMON VARIABLES variable "resource_group_name" { description = "Name of the resource group" type = string } -variable "resource_group_location" { +variable "location" { description = "Location of the resource group" type = string } +#______________________________________________________________________________| -variable "network_name" { +# NETWORK's VARIABLES +variable "prefix" { + type = string + default = "myapp" +} + +variable "virtual_network_name" { description = "Name of the virtual network" type = string default = "vnet" } -variable "v_net_address_prefix" { +variable "vnet_address_prefix" { description = "Virtual network address prefix" type = list(string) default = ["10.0.0.0/16"] @@ -34,7 +37,7 @@ variable "subnet_address_prefix" { type = list(string) default = ["10.0.0.0/24"] } -variable "pip_name" { +variable "public_ip_address_name" { description = "Name of the puplic ip resource" type = string default = "linuxboxpip" @@ -44,7 +47,7 @@ variable "dns_label" { type = string default = "matetask" } -variable "network_SG_name" { +variable "network_security_group_name" { description = "Name of Network Security Group" type = string default = "defaultnsg" @@ -88,4 +91,6 @@ variable "security_rules" { } ] } +#______________________________________________________________________________| + From ba97ed2c6c7b7ac3af883c401ad87afba9f521f6 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 00:02:24 +0300 Subject: [PATCH 04/13] Define Compote module Add compute to main.tf, fix install-app.sh script --- install-app.sh | 5 ++- main.tf | 13 ++++++ modules/compute/main.tf | 76 ++++++++++++++++++++++++++++++++++++ modules/compute/outputs.tf | 0 modules/compute/variables.tf | 51 ++++++++++++++++++++++++ modules/network/outputs.tf | 14 ++++--- variables.tf | 24 +++++++++++- 7 files changed, 174 insertions(+), 9 deletions(-) create mode 100644 modules/compute/main.tf create mode 100644 modules/compute/outputs.tf create mode 100644 modules/compute/variables.tf diff --git a/install-app.sh b/install-app.sh index 03706de..184cf1c 100644 --- a/install-app.sh +++ b/install-app.sh @@ -13,11 +13,12 @@ apt-get install python3-pip -yq # Create a directory for the app and download the files. mkdir /app # make sure to uncomment the line bellow and update the link with your GitHub username -# git clone https://github.com//azure_task_12_deploy_app_with_vm_extention.git +git clone https://github.com/AndS9/devops_todolist_terraform_task.git +chmod +x devops_todolist_terraform_task/app/start.sh cp -r devops_todolist_terraform_task/app/* /app # create a service for the app via systemctl and start the app mv /app/todoapp.service /etc/systemd/system/ systemctl daemon-reload systemctl start todoapp -systemctl enable todoapp +systemctl enable todoapp \ No newline at end of file diff --git a/main.tf b/main.tf index 69fcd82..7d33266 100644 --- a/main.tf +++ b/main.tf @@ -34,4 +34,17 @@ module "network" { dns_label = "${var.dns_label}-${random_string.suffix.result}" network_SG_name = var.network_security_group_name security_rules = var.security_rules +} +module "compute" { + source = "./modules/compute" + resource_group_name = var.resource_group_name + resource_group_location = var.location + vm_name = var.vm_name + vm_size = var.vm_size + subnet_id = module.network.subnet_id + public_ip_id = module.network.public_ip_id + NSG_id = module.network.NSG_id + extension_name = "CustomScript" + path_to_script = "install-app.sh" + SSH_key = "linuxboxsshkey" } \ No newline at end of file diff --git a/modules/compute/main.tf b/modules/compute/main.tf new file mode 100644 index 0000000..70c8ba7 --- /dev/null +++ b/modules/compute/main.tf @@ -0,0 +1,76 @@ +resource "azurerm_resource_group" "main" { + name = var.resource_group_name + location = var.resource_group_location +} + +resource "azurerm_network_interface" "main" { + name = "${var.vm_name}-nic" + location = azurerm_resource_group.main.location + resource_group_name = azurerm_resource_group.main.name + + ip_configuration { + name = "ip_config" + subnet_id = var.subnet_id + private_ip_address_allocation = "Dynamic" + public_ip_address_id = var.public_ip_id + } +} + +resource "azurerm_network_interface_security_group_association" "main" { + network_interface_id = azurerm_network_interface.main.id + network_security_group_id = var.NSG_id +} + +resource "azurerm_ssh_public_key" "example" { + name = var.SSH_key + resource_group_name = azurerm_resource_group.main.name + location = azurerm_resource_group.main.location + public_key = file("~/.ssh/id_rsa.pub") +} + +resource "azurerm_virtual_machine" "main" { + name = var.vm_name + location = azurerm_resource_group.main.location + resource_group_name = azurerm_resource_group.main.name + network_interface_ids = [azurerm_network_interface.main.id] + vm_size = var.vm_size + + storage_image_reference { + publisher = "Canonical" + offer = "0001-com-ubuntu-server-jammy" + sku = "22_04-lts" + version = "latest" + } + storage_os_disk { + name = "myosdisk1" + caching = "ReadWrite" + create_option = "FromImage" + managed_disk_type = "Standard_LRS" + } + os_profile { + computer_name = "hostname" + admin_username = "testadmin" + admin_password = "Password1234!" + } + os_profile_linux_config { + disable_password_authentication = false + + ssh_keys { + path = "/home/testadmin/.ssh/authorized_keys" + key_data = azurerm_ssh_public_key.example.public_key + } + } +} + +resource "azurerm_virtual_machine_extension" "example" { + name = var.extension_name + virtual_machine_id = azurerm_virtual_machine.main.id + publisher = "Microsoft.Azure.Extensions" + type = "CustomScript" + type_handler_version = "2.0" + + protected_settings = jsonencode({ + script = base64encode(file("${path.module}/../../${var.path_to_script}")) + }) + +} \ No newline at end of file diff --git a/modules/compute/outputs.tf b/modules/compute/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/modules/compute/variables.tf b/modules/compute/variables.tf new file mode 100644 index 0000000..60c471c --- /dev/null +++ b/modules/compute/variables.tf @@ -0,0 +1,51 @@ +variable "resource_group_name" { + description = "Name of the resource group" + type = string +} + +variable "resource_group_location" { + description = "Location of the resource group" + type = string +} + +variable "pip_name" { + description = "Name of public IP resource" + type = string + default = "linuxboxpip" +} + +variable "vm_name" { + description = "Virtual Machine Name" + type = string + default = "matebox" +} +variable "vm_size" { + description = "Size of VM" + type = string + default = "Standard_D2s_v3" +} + +variable "subnet_id" { + type = string +} + +variable "public_ip_id" { + type = string +} + +variable "NSG_id" { + type = string +} + +variable "extension_name" { + type = string + default = "CustomScript" +} +variable "path_to_script" { + type = string +} + +variable "SSH_key" { + type = string + default = "linuxboxsshkey" +} \ No newline at end of file diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf index e99d302..1f72b0e 100644 --- a/modules/network/outputs.tf +++ b/modules/network/outputs.tf @@ -1,9 +1,11 @@ -output "Virtal_network_id" { - value = azurerm_virtual_network.main.id +output "subnet_id" { + value = azurerm_subnet.internal.id } -output "Public_IP" { - value = azurerm_public_ip.mainIP.ip_address + +output "public_ip_id" { + value = azurerm_public_ip.mainIP.id } -output "Public_domain" { - value = azurerm_public_ip.mainIP.domain_name_label + +output "NSG_id" { + value = azurerm_network_security_group.main.id } \ No newline at end of file diff --git a/variables.tf b/variables.tf index a1d5f4c..ee8cd54 100644 --- a/variables.tf +++ b/variables.tf @@ -88,9 +88,31 @@ variable "security_rules" { destination_port_range = "80" source_address_prefix = "*" destination_address_prefix = "*" + }, + { + name = "HTTP-app" + priority = 300 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "8080" + source_address_prefix = "*" + destination_address_prefix = "*" } ] } #______________________________________________________________________________| - +# VIRTUAL MACHINE VARIABLES +variable "vm_name" { + description = "Virtual Machine Name" + type = string + default = "matebox" +} +variable "vm_size" { + description = "Size of VM" + type = string + default = "Standard_D2s_v3" +} +#______________________________________________________________________________| From 400748871a36945b624528bbb1e661784571a133 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 00:23:59 +0300 Subject: [PATCH 05/13] remove unused variable --- main.tf | 1 - modules/compute/outputs.tf | 6 ++++++ modules/network/outputs.tf | 7 ++++++- modules/network/variables.tf | 5 ----- variables.tf | 9 +++------ 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/main.tf b/main.tf index 7d33266..08a70c2 100644 --- a/main.tf +++ b/main.tf @@ -23,7 +23,6 @@ resource "random_string" "suffix" { } module "network" { source = "./modules/network" - prefix = var.prefix resource_group_name = var.resource_group_name resource_group_location = var.location network_name = var.virtual_network_name diff --git a/modules/compute/outputs.tf b/modules/compute/outputs.tf index e69de29..7aca773 100644 --- a/modules/compute/outputs.tf +++ b/modules/compute/outputs.tf @@ -0,0 +1,6 @@ +output "vm_id" { + value = azurerm_virtual_machine.main.id +} +output "ip_configuration" { + value = azurerm_network_interface.main.ip_configuration +} diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf index 1f72b0e..75dbc28 100644 --- a/modules/network/outputs.tf +++ b/modules/network/outputs.tf @@ -5,7 +5,12 @@ output "subnet_id" { output "public_ip_id" { value = azurerm_public_ip.mainIP.id } - +output "public_ip" { + value = azurerm_public_ip.mainIP.ip_address +} +output "public_domain" { + value = azurerm_public_ip.mainIP.domain_name_label +} output "NSG_id" { value = azurerm_network_security_group.main.id } \ No newline at end of file diff --git a/modules/network/variables.tf b/modules/network/variables.tf index e4aa285..28dfe26 100644 --- a/modules/network/variables.tf +++ b/modules/network/variables.tf @@ -1,8 +1,3 @@ -variable "prefix" { - type = string - default = "myapp" -} - variable "resource_group_name" { description = "Name of the resource group" type = string diff --git a/variables.tf b/variables.tf index ee8cd54..938ea7e 100644 --- a/variables.tf +++ b/variables.tf @@ -2,20 +2,17 @@ variable "resource_group_name" { description = "Name of the resource group" type = string + default = "mate-azure-task-12" } variable "location" { description = "Location of the resource group" type = string + default = "uksouth" } #______________________________________________________________________________| # NETWORK's VARIABLES -variable "prefix" { - type = string - default = "myapp" -} - variable "virtual_network_name" { description = "Name of the virtual network" type = string @@ -113,6 +110,6 @@ variable "vm_name" { variable "vm_size" { description = "Size of VM" type = string - default = "Standard_D2s_v3" + default = "Standard_B1s" } #______________________________________________________________________________| From 8d480c2efd93ba9a6954beb302270be2f77b8129 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 08:47:13 +0300 Subject: [PATCH 06/13] Define Storage Module Add storage to main.tf Reformat modules to use existing group resource --- backend.tf | 9 +++++++++ bootstrap/main.tf | 24 ++++++++++++++++++++++++ bootstrap/variables.tf | 12 ++++++++++++ main.tf | 22 ++++++++++++++++++---- modules/compute/main.tf | 17 ++++++----------- modules/network/main.tf | 20 +++++++------------- modules/storage/main.tf | 13 +++++++++++++ modules/storage/outputs.tf | 9 +++++++++ modules/storage/variables.tf | 21 +++++++++++++++++++++ outputs.tf | 24 ++++++++++++++++++++++++ tfplan | Bin 0 -> 15567 bytes variables.tf | 9 +++++++-- 12 files changed, 150 insertions(+), 30 deletions(-) create mode 100644 bootstrap/main.tf create mode 100644 bootstrap/variables.tf create mode 100644 modules/storage/main.tf create mode 100644 modules/storage/outputs.tf create mode 100644 modules/storage/variables.tf create mode 100644 tfplan diff --git a/backend.tf b/backend.tf index e69de29..c052490 100644 --- a/backend.tf +++ b/backend.tf @@ -0,0 +1,9 @@ +terraform { + backend "azurerm" { + storage_account_name = "ands9storageaccount" + container_name = "tfstate" + key = "terraform.tfstate" + resource_group_name = "mate-azure-task-12" + use_oidc = true + } +} diff --git a/bootstrap/main.tf b/bootstrap/main.tf new file mode 100644 index 0000000..a2cae2c --- /dev/null +++ b/bootstrap/main.tf @@ -0,0 +1,24 @@ +terraform { + required_providers { + azurerm = { + source = "hashicorp/azurerm" + version = "4.80.0" + } + } +} + +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = var.resource_group_name + location = var.resource_group_location +} +module "backend_storage" { + source = "../modules/storage" + resource_group_name = azurerm_resource_group.example.name + resource_group_location = azurerm_resource_group.example.location + storage_account_name = "ands9storageaccount" + container_name = "tfstate" +} \ No newline at end of file diff --git a/bootstrap/variables.tf b/bootstrap/variables.tf new file mode 100644 index 0000000..892c012 --- /dev/null +++ b/bootstrap/variables.tf @@ -0,0 +1,12 @@ +# COMMON VARIABLES +variable "resource_group_name" { + description = "Name of the resource group" + type = string + default = "mate-azure-task-12" +} +variable "resource_group_location" { + description = "Location of the resource group" + type = string + default = "uksouth" +} +#______________________________________________________________________________| \ No newline at end of file diff --git a/main.tf b/main.tf index 08a70c2..23ae139 100644 --- a/main.tf +++ b/main.tf @@ -15,16 +15,23 @@ provider "azurerm" { features { } + use_oidc = true } resource "random_string" "suffix" { length = 4 upper = false special = false } + +data "azurerm_resource_group" "main" { + name = var.resource_group_name +} + + module "network" { source = "./modules/network" - resource_group_name = var.resource_group_name - resource_group_location = var.location + resource_group_name = data.azurerm_resource_group.main.name + resource_group_location = data.azurerm_resource_group.main.location network_name = var.virtual_network_name v_net_address_prefix = var.vnet_address_prefix subnet_name = var.subnet_name @@ -36,8 +43,8 @@ module "network" { } module "compute" { source = "./modules/compute" - resource_group_name = var.resource_group_name - resource_group_location = var.location + resource_group_name = data.azurerm_resource_group.main.name + resource_group_location = data.azurerm_resource_group.main.location vm_name = var.vm_name vm_size = var.vm_size subnet_id = module.network.subnet_id @@ -46,4 +53,11 @@ module "compute" { extension_name = "CustomScript" path_to_script = "install-app.sh" SSH_key = "linuxboxsshkey" +} +module "storage" { + source = "./modules/storage" + resource_group_name = data.azurerm_resource_group.main.name + resource_group_location = data.azurerm_resource_group.main.location + storage_account_name = var.storage_account_name + container_name = "task-artifacts" } \ No newline at end of file diff --git a/modules/compute/main.tf b/modules/compute/main.tf index 70c8ba7..e4dc6d8 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -1,12 +1,7 @@ -resource "azurerm_resource_group" "main" { - name = var.resource_group_name - location = var.resource_group_location -} - resource "azurerm_network_interface" "main" { name = "${var.vm_name}-nic" - location = azurerm_resource_group.main.location - resource_group_name = azurerm_resource_group.main.name + location = var.resource_group_location + resource_group_name = var.resource_group_name ip_configuration { name = "ip_config" @@ -23,15 +18,15 @@ resource "azurerm_network_interface_security_group_association" "main" { resource "azurerm_ssh_public_key" "example" { name = var.SSH_key - resource_group_name = azurerm_resource_group.main.name - location = azurerm_resource_group.main.location + resource_group_name = var.resource_group_name + location = var.resource_group_location public_key = file("~/.ssh/id_rsa.pub") } resource "azurerm_virtual_machine" "main" { name = var.vm_name - location = azurerm_resource_group.main.location - resource_group_name = azurerm_resource_group.main.name + location = var.resource_group_location + resource_group_name = var.resource_group_name network_interface_ids = [azurerm_network_interface.main.id] vm_size = var.vm_size diff --git a/modules/network/main.tf b/modules/network/main.tf index af500d4..f9dc149 100644 --- a/modules/network/main.tf +++ b/modules/network/main.tf @@ -1,27 +1,21 @@ -resource "azurerm_resource_group" "main" { - name = var.resource_group_name - location = var.resource_group_location -} - - resource "azurerm_virtual_network" "main" { name = var.network_name address_space = ["10.0.0.0/16"] - location = azurerm_resource_group.main.location - resource_group_name = azurerm_resource_group.main.name + location = var.resource_group_location + resource_group_name = var.resource_group_name } resource "azurerm_subnet" "internal" { name = var.subnet_name - resource_group_name = azurerm_resource_group.main.name + resource_group_name = var.resource_group_name virtual_network_name = azurerm_virtual_network.main.name address_prefixes = ["10.0.0.0/24"] } resource "azurerm_public_ip" "mainIP" { name = var.pip_name - resource_group_name = azurerm_resource_group.main.name - location = azurerm_resource_group.main.location + resource_group_name = var.resource_group_name + location = var.resource_group_location allocation_method = "Static" sku = "Standard" domain_name_label = var.dns_label @@ -29,8 +23,8 @@ resource "azurerm_public_ip" "mainIP" { resource "azurerm_network_security_group" "main" { name = var.network_SG_name - location = azurerm_resource_group.main.location - resource_group_name = azurerm_resource_group.main.name + location = var.resource_group_location + resource_group_name = var.resource_group_name dynamic "security_rule" { for_each = var.security_rules diff --git a/modules/storage/main.tf b/modules/storage/main.tf new file mode 100644 index 0000000..025e3b2 --- /dev/null +++ b/modules/storage/main.tf @@ -0,0 +1,13 @@ +resource "azurerm_storage_account" "example" { + name = var.storage_account_name + resource_group_name = var.resource_group_name + location = var.resource_group_location + account_tier = "Standard" + account_replication_type = "LRS" +} + +resource "azurerm_storage_container" "example" { + name = var.container_name + storage_account_id = azurerm_storage_account.example.id + container_access_type = "private" +} \ No newline at end of file diff --git a/modules/storage/outputs.tf b/modules/storage/outputs.tf new file mode 100644 index 0000000..ced11f1 --- /dev/null +++ b/modules/storage/outputs.tf @@ -0,0 +1,9 @@ +output "storage_account_name" { + value = azurerm_storage_account.example.name +} +output "storage_account_id" { + value = azurerm_storage_account.example.id +} +output "container_id" { + value = azurerm_storage_container.example.id +} \ No newline at end of file diff --git a/modules/storage/variables.tf b/modules/storage/variables.tf new file mode 100644 index 0000000..3fff990 --- /dev/null +++ b/modules/storage/variables.tf @@ -0,0 +1,21 @@ +variable "resource_group_name" { + description = "The name of the resource group" + type = string + default = "example-resource-group" +} + +variable "resource_group_location" { + description = "The location of the resource group" + type = string + default = "Poland Central" +} + +variable "storage_account_name" { + description = "The unique_name across Azure of the storage account" + type = string +} + +variable "container_name" { + type = string + default = "storage_container" +} \ No newline at end of file diff --git a/outputs.tf b/outputs.tf index e69de29..91778f7 100644 --- a/outputs.tf +++ b/outputs.tf @@ -0,0 +1,24 @@ +output "resource_group" { + value = data.azurerm_resource_group.main.name +} +output "location" { + value = data.azurerm_resource_group.main.location +} + +output "vm_id" { + value = module.compute.vm_id +} +output "public_ip" { + value = module.network.public_ip +} +output "public_domain" { + value = module.network.public_domain +} +output "vm_ip_config" { + value = module.compute.ip_configuration +} + +output "container_taskartifacts_id" { + value = module.storage.container_id +} + diff --git a/tfplan b/tfplan new file mode 100644 index 0000000000000000000000000000000000000000..8f47d6d0b917d6dc36b1ede014d1221a34fd708e GIT binary patch literal 15567 zcma)jWmH|+vNi7Rt_RoP!QEW~!QF$qTX1)m0Kp-+ySux)yN3WD{od&AB(HCOx6ar< z_8DW>Shdz%v*xPWTV4tj3=IhC?MEeYrU~?uK>$GmIT+hm>RG8Mg98D-46B%*xLa6i z_B&oEe))9Nce!7R{yuR#U~OEYZJcdzwb|oHs?EV!ggzntGhMX{ru$2=3L5o zkKT12X#ya-3MM1CD1(}9mZpXn8(Rn|qA}Nf_aQV4O?;w8SAD`P;H!uNnps>8-&D2; zVe-=wq_a^d6b?l&Jk*N)So-_@krd|r^pxeg(ys(F2L}fTor!s!N`n8xTwoe}LEWnN6)> zCM?9M6CIramJCGTDy-!cEN#zdETCj(!64h41%K^Nh79G>s*|s1k8=Gc%OrsgBv8EN z%~#!S-en)80!^v!4o58v8T&blsKK+@^zkap*HNF5nB6>A?mB2CR?Au~Fs0L?kF3tv{$zV8%=>GYee+ zN(N~`8I1rQS^=SW{o!@aAx}{c6cQwq_*%YRms$Z_rTDA;$eboYP<9NZSeEORD$eVa z#g7qY2Cu#Nvcth(K+&~o8qH&Ezm8eyvJ`Fe)?rP&yvwY752|v`c3fQda5?!_70v4< zm4JI=&W4Wrk1Y(>_Pd91{+<_IRAf0gIT`#r!ykL>UXg;C2Z(Iw_9>x@z$~Mvw;FVE zXKHiL-peRPtXgy=$VYOJ4#`5v2gVe>O$b%R^v)!;G>A3?(8cABhy2JY?=MCM&g&j@ zEcGxncwbRaNgr$fwVmB4z{V%N+w*r`H6oCofxs4J<~khD2Cm z(4FYCapA1BCC+tzRbusSt}W|*^`N=dJicZiw(Z{6a2iin8RawtdkU}ou$S)sqMy#d ze_dm5ikbcRVR)Z$%=rMTMvNpzoP}E(q%xZ7oBz#z=YTLkvNI+`tt&k+Wzu)e=6*#m z&qAJXAiy1dijRPRn@J`5<|gK_+tSNH&(z}p>S)Ms!iJ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J^gEk`F9sT_tO3-{{L-*xPQ3#*Dm7k&VKGO{Ly~< z+s5&Jb@q=k;CFXF7xRA|8yL~A?*5@o@w>C13$TBruD|W*H)p?BTYvZTb2aIY^Z(!G zPx{NS{!{t(cZWaMcmB|OKN-b8I{XLq_q)%Z%NKu0vA?bTpMCyUEAsQ{_}9=`sD2sg zpXbE?-(3ED2>ms5nm3{R6a4;k_+Nzn^D*Ps(9voC(dT~^`p-GmZbJqp cpnuhq@>1Y$H5nivl((M?I1rEk`yY4z4?NU?;{X5v literal 0 HcmV?d00001 diff --git a/variables.tf b/variables.tf index 938ea7e..e0ab0b0 100644 --- a/variables.tf +++ b/variables.tf @@ -4,8 +4,7 @@ variable "resource_group_name" { type = string default = "mate-azure-task-12" } - -variable "location" { +variable "resource_group_location" { description = "Location of the resource group" type = string default = "uksouth" @@ -113,3 +112,9 @@ variable "vm_size" { default = "Standard_B1s" } #______________________________________________________________________________| + +# STORAGE ACCOUNT AND CONTAINER VARIABLES +variable "storage_account_name" { + type = string + default = "ands9prostorrage" +} \ No newline at end of file From a69787b503fa2b4c98702e4c3d4a9e8476b4186d Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 08:52:51 +0300 Subject: [PATCH 07/13] ResourceGroup in main.tf --- main.tf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.tf b/main.tf index 23ae139..fcd61aa 100644 --- a/main.tf +++ b/main.tf @@ -22,6 +22,15 @@ resource "random_string" "suffix" { upper = false special = false } +/* +I CAN"T USE IT IN MAIN, BECAUSE IT MUST BE CREATED WITH STORAGE ACC +BEFORE BACKEND for TERRAFORM TO PROPERLY START + +resource "azurerm_resource_group" "example" { + name = var.resource_group_name + location = var.resource_group_location +} +*/ data "azurerm_resource_group" "main" { name = var.resource_group_name From 9ee735fd90770f0abe131b4a1926bc1c2a71914e Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 09:09:15 +0300 Subject: [PATCH 08/13] Fix deprecated vm format to newer azurerm_linux_virtual_machine --- modules/compute/main.tf | 37 ++++++++++++++++--------------------- modules/compute/outputs.tf | 6 +++--- outputs.tf | 2 +- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/modules/compute/main.tf b/modules/compute/main.tf index e4dc6d8..9b9f43d 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -23,43 +23,38 @@ resource "azurerm_ssh_public_key" "example" { public_key = file("~/.ssh/id_rsa.pub") } -resource "azurerm_virtual_machine" "main" { +resource "azurerm_linux_virtual_machine" "main" { name = var.vm_name location = var.resource_group_location resource_group_name = var.resource_group_name network_interface_ids = [azurerm_network_interface.main.id] - vm_size = var.vm_size + size = var.vm_size - storage_image_reference { + + admin_username = "testadmin" + disable_password_authentication = true + computer_name = "todoapp-host" + source_image_reference { publisher = "Canonical" offer = "0001-com-ubuntu-server-jammy" sku = "22_04-lts" version = "latest" } - storage_os_disk { - name = "myosdisk1" - caching = "ReadWrite" - create_option = "FromImage" - managed_disk_type = "Standard_LRS" - } - os_profile { - computer_name = "hostname" - admin_username = "testadmin" - admin_password = "Password1234!" + os_disk { + name = "myosdisk1" + caching = "ReadWrite" + storage_account_type = "Standard_LRS" } - os_profile_linux_config { - disable_password_authentication = false - - ssh_keys { - path = "/home/testadmin/.ssh/authorized_keys" - key_data = azurerm_ssh_public_key.example.public_key - } + + admin_ssh_key { + username = "testadmin" + public_key = azurerm_ssh_public_key.example.public_key } } resource "azurerm_virtual_machine_extension" "example" { name = var.extension_name - virtual_machine_id = azurerm_virtual_machine.main.id + virtual_machine_id = azurerm_linux_virtual_machine.main.id publisher = "Microsoft.Azure.Extensions" type = "CustomScript" type_handler_version = "2.0" diff --git a/modules/compute/outputs.tf b/modules/compute/outputs.tf index 7aca773..77d1a67 100644 --- a/modules/compute/outputs.tf +++ b/modules/compute/outputs.tf @@ -1,6 +1,6 @@ output "vm_id" { - value = azurerm_virtual_machine.main.id + value = azurerm_linux_virtual_machine.main.id } -output "ip_configuration" { - value = azurerm_network_interface.main.ip_configuration +output "vm_public_ip_address" { + value = azurerm_linux_virtual_machine.main.public_ip_address } diff --git a/outputs.tf b/outputs.tf index 91778f7..aeda668 100644 --- a/outputs.tf +++ b/outputs.tf @@ -15,7 +15,7 @@ output "public_domain" { value = module.network.public_domain } output "vm_ip_config" { - value = module.compute.ip_configuration + value = module.compute.vm_public_ip_address } output "container_taskartifacts_id" { From 6fef7ba885789d4c5c6d4b8c8e2e733be8885b9f Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 09:13:39 +0300 Subject: [PATCH 09/13] Format code with terraform fmt --- modules/compute/main.tf | 12 ++++++------ modules/compute/outputs.tf | 2 +- modules/compute/variables.tf | 32 ++++++++++++++++---------------- modules/network/outputs.tf | 10 +++++----- modules/network/variables.tf | 18 +++++++++--------- modules/storage/variables.tf | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/modules/compute/main.tf b/modules/compute/main.tf index 9b9f43d..b6594e8 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -5,7 +5,7 @@ resource "azurerm_network_interface" "main" { ip_configuration { name = "ip_config" - subnet_id = var.subnet_id + subnet_id = var.subnet_id private_ip_address_allocation = "Dynamic" public_ip_address_id = var.public_ip_id } @@ -28,12 +28,12 @@ resource "azurerm_linux_virtual_machine" "main" { location = var.resource_group_location resource_group_name = var.resource_group_name network_interface_ids = [azurerm_network_interface.main.id] - size = var.vm_size - + size = var.vm_size - admin_username = "testadmin" + + admin_username = "testadmin" disable_password_authentication = true - computer_name = "todoapp-host" + computer_name = "todoapp-host" source_image_reference { publisher = "Canonical" offer = "0001-com-ubuntu-server-jammy" @@ -45,7 +45,7 @@ resource "azurerm_linux_virtual_machine" "main" { caching = "ReadWrite" storage_account_type = "Standard_LRS" } - + admin_ssh_key { username = "testadmin" public_key = azurerm_ssh_public_key.example.public_key diff --git a/modules/compute/outputs.tf b/modules/compute/outputs.tf index 77d1a67..88d3575 100644 --- a/modules/compute/outputs.tf +++ b/modules/compute/outputs.tf @@ -2,5 +2,5 @@ output "vm_id" { value = azurerm_linux_virtual_machine.main.id } output "vm_public_ip_address" { - value = azurerm_linux_virtual_machine.main.public_ip_address + value = azurerm_linux_virtual_machine.main.public_ip_address } diff --git a/modules/compute/variables.tf b/modules/compute/variables.tf index 60c471c..a7b9774 100644 --- a/modules/compute/variables.tf +++ b/modules/compute/variables.tf @@ -10,42 +10,42 @@ variable "resource_group_location" { variable "pip_name" { description = "Name of public IP resource" - type = string - default = "linuxboxpip" + type = string + default = "linuxboxpip" } variable "vm_name" { - description = "Virtual Machine Name" - type = string - default = "matebox" + description = "Virtual Machine Name" + type = string + default = "matebox" } variable "vm_size" { - description = "Size of VM" - type = string - default = "Standard_D2s_v3" + description = "Size of VM" + type = string + default = "Standard_D2s_v3" } variable "subnet_id" { - type = string + type = string } variable "public_ip_id" { - type = string + type = string } variable "NSG_id" { - type = string + type = string } variable "extension_name" { - type = string - default = "CustomScript" + type = string + default = "CustomScript" } variable "path_to_script" { - type = string + type = string } variable "SSH_key" { - type = string - default = "linuxboxsshkey" + type = string + default = "linuxboxsshkey" } \ No newline at end of file diff --git a/modules/network/outputs.tf b/modules/network/outputs.tf index 75dbc28..bcfb019 100644 --- a/modules/network/outputs.tf +++ b/modules/network/outputs.tf @@ -1,16 +1,16 @@ output "subnet_id" { - value = azurerm_subnet.internal.id + value = azurerm_subnet.internal.id } output "public_ip_id" { - value = azurerm_public_ip.mainIP.id + value = azurerm_public_ip.mainIP.id } output "public_ip" { - value = azurerm_public_ip.mainIP.ip_address + value = azurerm_public_ip.mainIP.ip_address } output "public_domain" { - value = azurerm_public_ip.mainIP.domain_name_label + value = azurerm_public_ip.mainIP.domain_name_label } output "NSG_id" { - value = azurerm_network_security_group.main.id + value = azurerm_network_security_group.main.id } \ No newline at end of file diff --git a/modules/network/variables.tf b/modules/network/variables.tf index 28dfe26..6009faf 100644 --- a/modules/network/variables.tf +++ b/modules/network/variables.tf @@ -11,7 +11,7 @@ variable "resource_group_location" { variable "network_name" { description = "Name of the virtual network" type = string - default = "vnet" + default = "vnet" } variable "v_net_address_prefix" { description = "Virtual network address prefix" @@ -19,9 +19,9 @@ variable "v_net_address_prefix" { default = ["10.0.0.0/16"] } variable "subnet_name" { - description = "Name of the subnet" - type = string - default = "default" + description = "Name of the subnet" + type = string + default = "default" } variable "subnet_address_prefix" { @@ -37,17 +37,17 @@ variable "pip_name" { variable "dns_label" { description = "DNS for service" type = string - default = "matetask" + default = "matetask" } variable "network_SG_name" { - description = "Name of Network Security Group" - type = string - default = "defaultnsg" + description = "Name of Network Security Group" + type = string + default = "defaultnsg" } variable "security_rules" { description = "List of security rules for the network security group" - type = list(object({ + type = list(object({ name = string priority = number direction = string diff --git a/modules/storage/variables.tf b/modules/storage/variables.tf index 3fff990..7ca6d1d 100644 --- a/modules/storage/variables.tf +++ b/modules/storage/variables.tf @@ -16,6 +16,6 @@ variable "storage_account_name" { } variable "container_name" { - type = string + type = string default = "storage_container" } \ No newline at end of file From 23b40a810a4965270770332acdb1576635227bfe Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 09:25:54 +0300 Subject: [PATCH 10/13] Add public_key --- id_rsa.pub | 1 + modules/compute/main.tf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 id_rsa.pub diff --git a/id_rsa.pub b/id_rsa.pub new file mode 100644 index 0000000..61aedd8 --- /dev/null +++ b/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCIyUeZK9634jxA/Er9Z36ut8N3EqTklrYqUP2hKxFNFqi/fa1H0AN4ucx7JJwZIrrVEQ97MzHKuTs7FncmL8lPDaxQtIKTORHlPIRU1HfKSMtdQVY9jaFBYVTmkDW6hMXCYUuCgyf3QVv16fqdBbNqbkH+7mR56Attu1+X4szC3MFze+sW+y0hznxsdoibAnrpjOt2EtCpAlCbI3a7ksn/YvBWMAnYz0alVy7tz8nm8/2pf7iAGCpUKrREh86XLmqtjfao/8jps7rXa6+OLzOTX6/IaGJiKTT7CAorkZvh4JxCrVTY0xSlFr4/FP/E//M2aoq1lL2/01FnRTUly63j rsa-key-20260607 \ No newline at end of file diff --git a/modules/compute/main.tf b/modules/compute/main.tf index b6594e8..375faf1 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -20,7 +20,7 @@ resource "azurerm_ssh_public_key" "example" { name = var.SSH_key resource_group_name = var.resource_group_name location = var.resource_group_location - public_key = file("~/.ssh/id_rsa.pub") + public_key = file("${path.module}/../../id_rsa.pub") } resource "azurerm_linux_virtual_machine" "main" { From be6e2c77556c1b907c7b598f45086bdbf141e529 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 09:47:14 +0300 Subject: [PATCH 11/13] Update to use ssh_pub_content --- id_rsa.pub | 1 - main.tf | 1 + modules/compute/main.tf | 2 +- modules/compute/variables.tf | 4 ++++ variables.tf | 4 ++++ 5 files changed, 10 insertions(+), 2 deletions(-) delete mode 100644 id_rsa.pub diff --git a/id_rsa.pub b/id_rsa.pub deleted file mode 100644 index 61aedd8..0000000 --- a/id_rsa.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCIyUeZK9634jxA/Er9Z36ut8N3EqTklrYqUP2hKxFNFqi/fa1H0AN4ucx7JJwZIrrVEQ97MzHKuTs7FncmL8lPDaxQtIKTORHlPIRU1HfKSMtdQVY9jaFBYVTmkDW6hMXCYUuCgyf3QVv16fqdBbNqbkH+7mR56Attu1+X4szC3MFze+sW+y0hznxsdoibAnrpjOt2EtCpAlCbI3a7ksn/YvBWMAnYz0alVy7tz8nm8/2pf7iAGCpUKrREh86XLmqtjfao/8jps7rXa6+OLzOTX6/IaGJiKTT7CAorkZvh4JxCrVTY0xSlFr4/FP/E//M2aoq1lL2/01FnRTUly63j rsa-key-20260607 \ No newline at end of file diff --git a/main.tf b/main.tf index fcd61aa..d3f4ba3 100644 --- a/main.tf +++ b/main.tf @@ -62,6 +62,7 @@ module "compute" { extension_name = "CustomScript" path_to_script = "install-app.sh" SSH_key = "linuxboxsshkey" + ssh_public_key_content = var.ssh_key_public } module "storage" { source = "./modules/storage" diff --git a/modules/compute/main.tf b/modules/compute/main.tf index 375faf1..da0df3a 100644 --- a/modules/compute/main.tf +++ b/modules/compute/main.tf @@ -20,7 +20,7 @@ resource "azurerm_ssh_public_key" "example" { name = var.SSH_key resource_group_name = var.resource_group_name location = var.resource_group_location - public_key = file("${path.module}/../../id_rsa.pub") + public_key = var.ssh_public_key_content } resource "azurerm_linux_virtual_machine" "main" { diff --git a/modules/compute/variables.tf b/modules/compute/variables.tf index a7b9774..b0ee9f5 100644 --- a/modules/compute/variables.tf +++ b/modules/compute/variables.tf @@ -48,4 +48,8 @@ variable "path_to_script" { variable "SSH_key" { type = string default = "linuxboxsshkey" +} + +variable "ssh_public_key_content" { + type = string } \ No newline at end of file diff --git a/variables.tf b/variables.tf index e0ab0b0..d0d1bb7 100644 --- a/variables.tf +++ b/variables.tf @@ -111,6 +111,10 @@ variable "vm_size" { type = string default = "Standard_B1s" } +variable "ssh_key_public" { + type = string + default = "your-public-key-conten" +} #______________________________________________________________________________| # STORAGE ACCOUNT AND CONTAINER VARIABLES From 9557b95b8ad76d3613760322ba4ff09df01fcb82 Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 09:55:54 +0300 Subject: [PATCH 12/13] Fixes to approve --- backend.tf | 2 +- modules/compute/outputs.tf | 3 --- modules/compute/variables.tf | 2 +- modules/network/main.tf | 2 +- outputs.tf | 3 --- 5 files changed, 3 insertions(+), 9 deletions(-) diff --git a/backend.tf b/backend.tf index c052490..cdd7651 100644 --- a/backend.tf +++ b/backend.tf @@ -1,6 +1,6 @@ terraform { backend "azurerm" { - storage_account_name = "ands9storageaccount" + storage_account_name = "yourstorageaccount" container_name = "tfstate" key = "terraform.tfstate" resource_group_name = "mate-azure-task-12" diff --git a/modules/compute/outputs.tf b/modules/compute/outputs.tf index 88d3575..5474853 100644 --- a/modules/compute/outputs.tf +++ b/modules/compute/outputs.tf @@ -1,6 +1,3 @@ output "vm_id" { value = azurerm_linux_virtual_machine.main.id } -output "vm_public_ip_address" { - value = azurerm_linux_virtual_machine.main.public_ip_address -} diff --git a/modules/compute/variables.tf b/modules/compute/variables.tf index b0ee9f5..8e3a9f1 100644 --- a/modules/compute/variables.tf +++ b/modules/compute/variables.tf @@ -22,7 +22,7 @@ variable "vm_name" { variable "vm_size" { description = "Size of VM" type = string - default = "Standard_D2s_v3" + default = "Standard_B1s" } variable "subnet_id" { diff --git a/modules/network/main.tf b/modules/network/main.tf index f9dc149..f68a619 100644 --- a/modules/network/main.tf +++ b/modules/network/main.tf @@ -16,7 +16,7 @@ resource "azurerm_public_ip" "mainIP" { name = var.pip_name resource_group_name = var.resource_group_name location = var.resource_group_location - allocation_method = "Static" + allocation_method = "Dynamic" sku = "Standard" domain_name_label = var.dns_label } diff --git a/outputs.tf b/outputs.tf index aeda668..b9ea170 100644 --- a/outputs.tf +++ b/outputs.tf @@ -14,9 +14,6 @@ output "public_ip" { output "public_domain" { value = module.network.public_domain } -output "vm_ip_config" { - value = module.compute.vm_public_ip_address -} output "container_taskartifacts_id" { value = module.storage.container_id From 8a5afdef0780f7d405ac8ffc0a071b66bea520db Mon Sep 17 00:00:00 2001 From: Andrii Shukalo Date: Tue, 14 Jul 2026 10:04:27 +0300 Subject: [PATCH 13/13] Fixes --- bootstrap/main.tf | 2 +- main.tf | 2 +- variables.tf | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bootstrap/main.tf b/bootstrap/main.tf index a2cae2c..005848a 100644 --- a/bootstrap/main.tf +++ b/bootstrap/main.tf @@ -19,6 +19,6 @@ module "backend_storage" { source = "../modules/storage" resource_group_name = azurerm_resource_group.example.name resource_group_location = azurerm_resource_group.example.location - storage_account_name = "ands9storageaccount" + storage_account_name = "yourstorageaccount" container_name = "tfstate" } \ No newline at end of file diff --git a/main.tf b/main.tf index d3f4ba3..865773d 100644 --- a/main.tf +++ b/main.tf @@ -68,6 +68,6 @@ module "storage" { source = "./modules/storage" resource_group_name = data.azurerm_resource_group.main.name resource_group_location = data.azurerm_resource_group.main.location - storage_account_name = var.storage_account_name + storage_account_name = var.storage_account_name_for_artifacts container_name = "task-artifacts" } \ No newline at end of file diff --git a/variables.tf b/variables.tf index d0d1bb7..b058d95 100644 --- a/variables.tf +++ b/variables.tf @@ -113,12 +113,16 @@ variable "vm_size" { } variable "ssh_key_public" { type = string - default = "your-public-key-conten" + default = "your-public-key-content" } #______________________________________________________________________________| # STORAGE ACCOUNT AND CONTAINER VARIABLES variable "storage_account_name" { + type = string + default = "yourstorageaccount" +} +variable "storage_account_name_for_artifacts" { type = string default = "ands9prostorrage" -} \ No newline at end of file +}