-
Notifications
You must be signed in to change notification settings - Fork 70
Todo deploy #46
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
kenu21
wants to merge
8
commits into
mate-academy:main
Choose a base branch
from
kenu21:todo-deploy
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
Todo deploy #46
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
af8ce8a
todo-deploy: added gitignore
1a6cfeb
todo-deploy: added structure
f5ba0d5
todo-deploy: changed gitignore
0e356c6
tododeploy: added implementation
fae8282
todo-deploy: refactored
bcf1df6
todo-develop: updated gitignore
086e62f
todo-deploy: fixed test
783873a
todo-deploy: added comment
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
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,37 @@ | ||
| # 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.json | ||
|
kenu21 marked this conversation as resolved.
|
||
| *.tfvars | ||
|
|
||
| # 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 | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
| terraform { | ||
| backend "azurerm" { | ||
| resource_group_name = "mate-azure-task-12" | ||
| storage_account_name = "yuriikeniustorageaccount" | ||
|
kenu21 marked this conversation as resolved.
kenu21 marked this conversation as resolved.
kenu21 marked this conversation as resolved.
|
||
| container_name = "tfstate" | ||
| key = "terraform.tfstate" | ||
| } | ||
| } | ||
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,58 @@ | ||
| terraform { | ||
| required_providers { | ||
| azurerm = { | ||
| source = "hashicorp/azurerm" | ||
| version = "4.52.0" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| provider "azurerm" { | ||
| features {} | ||
|
|
||
| subscription_id = var.subscription_id | ||
| } | ||
|
kenu21 marked this conversation as resolved.
|
||
|
|
||
| data "azurerm_resource_group" "rg" { | ||
| name = var.resource_group_name | ||
| } | ||
|
kenu21 marked this conversation as resolved.
kenu21 marked this conversation as resolved.
|
||
|
|
||
| module "network" { | ||
| source = "./modules/network" | ||
|
|
||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| virtual_network_name = var.virtual_network_name | ||
| vnet_address_prefix = var.vnet_address_prefix | ||
| 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_prefix = var.dns_label | ||
| vm_name = var.vm_name | ||
| } | ||
|
|
||
| module "storage" { | ||
| source = "./modules/storage" | ||
|
|
||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| storage_account_name = var.storage_account_name | ||
| install_app_script_path = var.install_app_script_path | ||
| } | ||
|
|
||
| module "compute" { | ||
| source = "./modules/compute" | ||
|
|
||
| resource_group_name = var.resource_group_name | ||
| subnet_id = module.network.subnet_id | ||
| public_ip_id = module.network.public_ip_id | ||
| location = var.location | ||
| vm_name = var.vm_name | ||
| admin_username = var.admin_username | ||
| admin_ssh_key = var.ssh_key_public | ||
| vm_size = var.vm_size | ||
| storage_account_name = var.storage_account_name | ||
| storage_account_key = module.storage.storage_account_primary_key | ||
| container_name = var.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,65 @@ | ||
| resource "azurerm_network_interface" "vm_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.public_ip_id | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_linux_virtual_machine" "vm" { | ||
| name = var.vm_name | ||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| size = var.vm_size | ||
| admin_username = var.admin_username | ||
|
|
||
| network_interface_ids = [ | ||
| azurerm_network_interface.vm_nic.id, | ||
| ] | ||
|
|
||
| admin_ssh_key { | ||
| username = var.admin_username | ||
| public_key = var.admin_ssh_key | ||
| } | ||
|
|
||
| os_disk { | ||
| caching = "ReadWrite" | ||
| storage_account_type = "Standard_LRS" | ||
| } | ||
|
|
||
| source_image_reference { | ||
| publisher = "Canonical" | ||
| offer = "0001-com-ubuntu-server-jammy" | ||
| sku = "22_04-lts-gen2" | ||
| version = "latest" | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_virtual_machine_extension" "custom_script" { | ||
| name = "install-app" | ||
| virtual_machine_id = azurerm_linux_virtual_machine.vm.id | ||
| publisher = "Microsoft.Azure.Extensions" | ||
| type = "CustomScript" | ||
| type_handler_version = "2.1" | ||
|
|
||
| settings = jsonencode({ | ||
| fileUris = [ | ||
| "https://${var.storage_account_name}.blob.core.windows.net/${var.container_name}/install-app.sh" | ||
| ] | ||
| commandToExecute = "bash install-app.sh" | ||
| }) | ||
|
|
||
| protected_settings = jsonencode({ | ||
| storageAccountName = var.storage_account_name | ||
| storageAccountKey = var.storage_account_key | ||
| }) | ||
|
|
||
| depends_on = [ | ||
| azurerm_linux_virtual_machine.vm | ||
| ] | ||
| } |
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,54 @@ | ||
| variable "subnet_id" { | ||
| description = "ID of the subnet for the VM's network interface" | ||
| type = string | ||
| } | ||
|
|
||
| variable "public_ip_id" { | ||
| description = "ID of the Public IP assigned to the VM's network interface" | ||
| type = string | ||
| } | ||
|
|
||
| variable "resource_group_name" { | ||
| description = "Name of the resource group" | ||
| type = string | ||
| } | ||
|
|
||
| variable "location" { | ||
| description = "Azure region for resources" | ||
| type = string | ||
| } | ||
|
|
||
| variable "vm_name" { | ||
| description = "Name of the virtual machine" | ||
| type = string | ||
| } | ||
|
|
||
| variable "admin_username" { | ||
| description = "Admin username for the virtual machine" | ||
| type = string | ||
| } | ||
|
|
||
| variable "admin_ssh_key" { | ||
| description = "SSH public key for the virtual machine" | ||
| type = string | ||
| } | ||
|
|
||
| variable "vm_size" { | ||
| description = "Size of the virtual machine" | ||
| type = string | ||
| } | ||
|
|
||
| variable "storage_account_name" { | ||
| description = "Storage account name where install-app.sh script is stored" | ||
| type = string | ||
| } | ||
|
|
||
| variable "storage_account_key" { | ||
| description = "Storage account key for accessing the script" | ||
| type = string | ||
| } | ||
|
|
||
| variable "container_name" { | ||
| description = "Container name where install-app.sh script is stored" | ||
| 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,56 @@ | ||
| resource "random_integer" "dns_suffix" { | ||
| min = 1000 | ||
| max = 9999 | ||
| } | ||
|
|
||
| resource "azurerm_virtual_network" "vnet" { | ||
| name = var.virtual_network_name | ||
| address_space = [var.vnet_address_prefix] | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
| } | ||
|
|
||
| resource "azurerm_subnet" "default" { | ||
| 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" "defaultnsg" { | ||
| name = var.network_security_group_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
|
|
||
| dynamic "security_rule" { | ||
| for_each = [ | ||
| { name = "Allow-SSH", priority = 100, direction = "Inbound", access = "Allow", protocol = "Tcp", port = 22 }, | ||
| { name = "Allow-HTTP", priority = 200, direction = "Inbound", access = "Allow", protocol = "Tcp", port = 80 }, | ||
| { name = "Allow-HTTP2", priority = 300, direction = "Inbound", access = "Allow", protocol = "Tcp", port = 8080 } | ||
| ] | ||
| 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 = "*" | ||
| destination_port_range = security_rule.value.port | ||
| source_address_prefix = "*" | ||
| destination_address_prefix = "*" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_subnet_network_security_group_association" "default" { | ||
| subnet_id = azurerm_subnet.default.id | ||
| network_security_group_id = azurerm_network_security_group.defaultnsg.id | ||
| } | ||
|
|
||
| resource "azurerm_public_ip" "linuxboxpip" { | ||
| name = var.public_ip_address_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
| allocation_method = "Static" | ||
|
kenu21 marked this conversation as resolved.
kenu21 marked this conversation as resolved.
kenu21 marked this conversation as resolved.
|
||
| domain_name_label = "${var.dns_label_prefix}${random_integer.dns_suffix.result}" | ||
| } | ||
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,9 @@ | ||
| output "subnet_id" { | ||
| description = "The ID of the subnet used for the virtual machine." | ||
| value = azurerm_subnet.default.id | ||
| } | ||
|
|
||
| output "public_ip_id" { | ||
| description = "The ID of the Public IP address associated with the virtual machine." | ||
| value = azurerm_public_ip.linuxboxpip.id | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.