-
Notifications
You must be signed in to change notification settings - Fork 70
Dev #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dimak20
wants to merge
8
commits into
mate-academy:main
Choose a base branch
from
dimak20:dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dev #56
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"network_module","Source":"./modules/network","Dir":"modules/network"},{"Key":"storage_module","Source":"./modules/storage","Dir":"modules/storage"},{"Key":"vm_module","Source":"./modules/compute","Dir":"modules/compute"}]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| terraform { | ||
| required_providers { | ||
| azurerm = { | ||
| source = "hashicorp/azurerm" | ||
| version = "3.105.0" | ||
| } | ||
| random = { | ||
| source = "hashicorp/random" | ||
| version = "~> 3.0" | ||
| } | ||
| } | ||
|
|
||
| backend "azurerm" { | ||
| resource_group_name = "mate-azure-task-12" | ||
| storage_account_name = "yourstorageaccount" | ||
| container_name = "tfstate" | ||
| key = "terraform.tfstate" | ||
| use_oidc = true | ||
| } | ||
| } | ||
|
|
||
| provider "azurerm" { | ||
| features {} | ||
| use_oidc = true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| resource "azurerm_resource_group" "rg" { | ||
| name = var.resource_group_name | ||
| location = var.location | ||
| } | ||
| module "network_module" { | ||
| source = "./modules/network" | ||
| virtual_network_name = var.virtual_network_name | ||
| vnet_address_prefix = var.vnet_address_prefix | ||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| subnet_name = var.subnet_name | ||
| subnet_address_prefix = var.subnet_address_prefix | ||
| network_security_group_name = var.network_security_group_name | ||
| public_ip_address_name = var.public_ip_address_name | ||
| dns_label = var.dns_label | ||
| } | ||
| module "storage_module" { | ||
| source = "./modules/storage" | ||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| storage_account_name = var.storage_account_name | ||
| storage_container_name = var.storage_container_name | ||
| } | ||
| module "vm_module" { | ||
| source = "./modules/compute" | ||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| vm_name = var.vm_name | ||
| vm_size = var.vm_size | ||
| ssh_key_public = var.ssh_key_public | ||
| subnet_id = module.network_module.subnet_id | ||
| pip_id = module.network_module.public_ip_id | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| resource "azurerm_network_interface" "nic" { | ||
| name = "${var.vm_name}-nic" | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
|
|
||
|
|
||
| ip_configuration { | ||
| name = "internal" | ||
| subnet_id = var.subnet_id | ||
| private_ip_address_allocation = "Dynamic" | ||
| public_ip_address_id = var.pip_id | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_linux_virtual_machine" "main" { | ||
| name = var.vm_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
| network_interface_ids = [azurerm_network_interface.nic.id] | ||
| size = var.vm_size | ||
|
|
||
| source_image_reference { | ||
| publisher = "Canonical" | ||
| offer = "0001-com-ubuntu-server-jammy" | ||
| sku = "22_04-lts" | ||
| version = "latest" | ||
| } | ||
|
|
||
| os_disk { | ||
| name = "${var.vm_name}-osdisk" | ||
| caching = "ReadWrite" | ||
| storage_account_type = "Standard_LRS" | ||
| } | ||
|
|
||
| computer_name = "matebox" | ||
| admin_username = "azureuser" | ||
|
|
||
| admin_ssh_key { | ||
| username = "azureuser" | ||
| public_key = var.ssh_key_public | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_virtual_machine_extension" "api_install" { | ||
| name = "install-api" | ||
| virtual_machine_id = azurerm_linux_virtual_machine.main.id | ||
| publisher = "Microsoft.Azure.Extensions" | ||
| type = "CustomScript" | ||
| type_handler_version = "2.1" | ||
|
|
||
| settings = <<SETTINGS | ||
| { | ||
| "fileUris": ["https://raw.githubusercontent.com/dimak20/azure_task_12_deploy_app_with_vm_extention/main/install-app.sh"], | ||
| "commandToExecute": "bash install-app.sh" | ||
| } | ||
| SETTINGS | ||
| } |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| variable "vm_name" { | ||
| description = "The name of the virtual machine." | ||
| type = string | ||
| } | ||
| variable "location" { | ||
| description = "The location of the virtual machine." | ||
| type = string | ||
| } | ||
| variable "resource_group_name" { | ||
| description = "The name of the resource group." | ||
| type = string | ||
| } | ||
| variable "subnet_id" { | ||
| description = "The ID of the subnet." | ||
| type = string | ||
| } | ||
| variable "pip_id" { | ||
| description = "The ID of the public ip address" | ||
| type = string | ||
| } | ||
| variable "vm_size" { | ||
| description = "The size of the virtual machine." | ||
| type = string | ||
| } | ||
| variable "ssh_key_public" { | ||
| description = "The public SSH key for the virtual machine." | ||
| type = string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| resource "azurerm_virtual_network" "vnet" { | ||
| name = var.virtual_network_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
| address_space = [var.vnet_address_prefix] | ||
| } | ||
| resource "azurerm_subnet" "internal" { | ||
| name = var.subnet_name | ||
| resource_group_name = var.resource_group_name | ||
| virtual_network_name = azurerm_virtual_network.vnet.name | ||
| address_prefixes = [var.subnet_address_prefix] | ||
| } | ||
| resource "azurerm_network_security_group" "nsg" { | ||
| name = var.network_security_group_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
|
|
||
| security_rule { | ||
| name = "SSH" | ||
| priority = 1001 | ||
| direction = "Inbound" | ||
| access = "Allow" | ||
| protocol = "Tcp" | ||
| source_port_range = "*" | ||
| destination_port_range = "22" | ||
| source_address_prefix = "*" | ||
| destination_address_prefix = "*" | ||
| } | ||
| security_rule { | ||
| name = "HTTP" | ||
| priority = 1002 | ||
| direction = "Inbound" | ||
| access = "Allow" | ||
| protocol = "Tcp" | ||
| source_port_range = "*" | ||
| destination_port_range = "80" | ||
| source_address_prefix = "*" | ||
| destination_address_prefix = "*" | ||
| } | ||
| security_rule { | ||
| name = "HTTPS" | ||
| priority = 1003 | ||
| direction = "Inbound" | ||
| access = "Allow" | ||
| protocol = "Tcp" | ||
| source_port_range = "*" | ||
| destination_port_range = "443" | ||
| source_address_prefix = "*" | ||
| destination_address_prefix = "*" | ||
| } | ||
| security_rule { | ||
| name = "API" | ||
| priority = 1004 | ||
| direction = "Inbound" | ||
| access = "Allow" | ||
| protocol = "Tcp" | ||
| source_port_range = "*" | ||
| destination_port_range = "8080" | ||
| source_address_prefix = "*" | ||
| destination_address_prefix = "*" | ||
| } | ||
| } | ||
| resource "random_integer" "random_id" { | ||
| min = 1000 | ||
| max = 9999 | ||
| } | ||
|
|
||
| resource "azurerm_public_ip" "pip" { | ||
| name = var.public_ip_address_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
| allocation_method = "Dynamic" | ||
| sku = "Basic" | ||
|
|
||
| domain_name_label = "${var.dns_label}-${random_integer.random_id.result}" | ||
| } | ||
|
|
||
| resource "azurerm_subnet_network_security_group_association" "nsg_assoc" { | ||
| subnet_id = azurerm_subnet.internal.id | ||
| network_security_group_id = azurerm_network_security_group.nsg.id | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| output "public_ip_id" { | ||
| value = azurerm_public_ip.pip.id | ||
| } | ||
| output "nsg_id" { | ||
| value = azurerm_network_security_group.nsg.id | ||
| } | ||
| output "subnet_id" { | ||
| value = azurerm_subnet.internal.id | ||
| } | ||
| output "public_ip_fqdn" { | ||
| value = azurerm_public_ip.pip.fqdn | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| variable "virtual_network_name" { | ||
| description = "The name of the virtual network." | ||
| type = string | ||
| } | ||
| variable "vnet_address_prefix" { | ||
| description = "The address space for the virtual network." | ||
| type = string | ||
| } | ||
| variable "resource_group_name" { | ||
| description = "The name of the resource group." | ||
| type = string | ||
| } | ||
| variable "location" { | ||
| description = "The location of the resources." | ||
| type = string | ||
| } | ||
| variable "subnet_name" { | ||
| description = "The name of the subnet." | ||
| type = string | ||
| } | ||
| variable "subnet_address_prefix" { | ||
| description = "The address prefix for the subnet." | ||
| type = string | ||
| } | ||
| variable "network_security_group_name" { | ||
| description = "The name of the network security group." | ||
| type = string | ||
| } | ||
| variable "public_ip_address_name" { | ||
| description = "The name of the public IP address." | ||
| type = string | ||
| } | ||
| variable "dns_label" { | ||
| description = "The DNS label for the public IP address." | ||
| type = string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| resource "azurerm_storage_account" "storage_account" { | ||
| name = var.storage_account_name | ||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| account_tier = "Standard" | ||
| account_replication_type = "LRS" | ||
| } | ||
| resource "azurerm_storage_container" "container" { | ||
| name = var.storage_container_name | ||
| storage_account_name = azurerm_storage_account.storage_account.name | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| output "storage_account_name" { | ||
| value = azurerm_storage_account.storage_account.name | ||
| } | ||
| output "storage_container_name" { | ||
| value = azurerm_storage_container.container.name | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| variable "location" { | ||
| description = "Location of the storage account" | ||
| type = string | ||
| } | ||
| variable "resource_group_name" { | ||
| description = "Name of the resource group" | ||
| type = string | ||
| } | ||
| variable "storage_account_name" { | ||
| description = "Name of the storage account" | ||
| type = string | ||
| } | ||
| variable "storage_container_name" { | ||
| description = "Name of the storage container" | ||
| type = string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| output "public_ip_fqdn" { | ||
| value = module.network_module.public_ip_fqdn | ||
| } | ||
|
|
||
| output "vm_name" { | ||
| value = var.vm_name | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| location = "uksouth" | ||
| resource_group_name = "mate-azure-task-12" | ||
| virtual_network_name = "vnet" | ||
| vnet_address_prefix = "10.0.0.0/16" | ||
| subnet_name = "default" | ||
| subnet_address_prefix = "10.0.0.0/24" | ||
| network_security_group_name = "defaultnsg" | ||
| public_ip_address_name = "linuxboxpip" | ||
| vm_name = "matebox" | ||
| vm_size = "Standard_B1s" | ||
| ssh_key_public = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDYmf9RefboNxShzSA8q80ZcBcV2yBGS3ejlnU+AuZ3Q62zgzRzmbAgvVSELvVd77TpQC/+6KyRQjOoU86tuNEVgZNrSJ5rLkrntExKCOb9mmhWKqquxSLkvPrG6HhnF/mjODERA0WxPe0ceYO2qX5W2WHonynEt2JpW3VArbFD0SkFM/zu4UySOEtTyQijYhQxGZ9+pGtWz1RQYTaYzetFN3g9L08P31ng1nrNs9FdYR50xmSkm+S8KsSR6gQTHF6F1OFxLL8APWL1/IJNf+xKDBLbFcjEPZnMvwkp04qjn3K/exHdLennInOmT0Z+Vnd4wqzXzRu+4LeQitiOJUAx+cZVLddolmHZU9hW+b5eBogdx3CozcFUUrZfhVIsJJFfZGbloDXXV8PlMOTWeDOU5/oA/9s3I0Vwls2FirSvP0M4MGo7/l6UfMM3F5GSwatrs5EXChrbQbl9Ru5FpMAx56v5VjClRwb0XhYZVCGCxYsbZaBRpE3YmfZhCkoA6Y2sk7578gnzEVDqWgPDiGGA+wpUuQVPiuuU9oX24QYrgxnq0m1834vgAOBUacfhQ6GKVGeuM6CJXciEh+x1gBkaAcf/D/8vF80cf50HNyExSDz8WgSsBWQa2KSMkHqP5hK2ZhoL6BtpEaWM5QeYGJ5z6cEq+7ghg9f3yzZEO7wxJQ== acernitro7@DESKTOP-DL5L0MS" | ||
| dns_label = "matetask" | ||
| storage_account_name = "dimak100task12" | ||
| storage_container_name = "task-artifacts" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The task requires creating all necessary resources, including the resource group. This
datablock fetches an existing resource group instead of creating a new one. You should use anazurerm_resource_groupresource block to create the group managed by this Terraform configuration.