-
Notifications
You must be signed in to change notification settings - Fork 67
created the terraform infrastructure for deploy todoapp #69
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .terraform/ | ||
| *.tfstate | ||
| *.tfstate.* | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| terraform { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist Item #7 Violation: Location must be |
||
| required_providers { | ||
| azurerm = { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined variable: |
||
| source = "hashicorp/azurerm" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| version = "3.105.0" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Undefined variable: |
||
| } | ||
| } | ||
|
|
||
| backend "azurerm" { | ||
| resource_group_name = "mate-azure-task-12" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist Item #10 Violation: vm_size must be |
||
| storage_account_name = "storagejghae7" | ||
| container_name = "task-artifacts" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist Item #27 Violation: Backend container_name should be |
||
| key = "terraform.tfstate" | ||
| } | ||
| } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist Item #19 Violation: Public IP allocation_method should be |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| provider "azurerm" { | ||
| features {} | ||
| subscription_id = "6a8d93ad-791e-41b1-a745-b6c493b83991" | ||
| } | ||
|
|
||
|
|
||
|
|
||
| resource "azurerm_resource_group" "example" { | ||
| name = var.resource_group_name | ||
| location = var.location | ||
| } | ||
|
|
||
|
|
||
| module "compute" { | ||
|
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate output: |
||
| source = "./modules/compute" | ||
| network_security_group_id = module.network.network_security_group_id | ||
| resource_group_name = azurerm_resource_group.example.name | ||
| location = azurerm_resource_group.example.location | ||
|
|
||
| vm_name = var.vm_name | ||
| vm_size = var.vm_size | ||
| ssh_key_public = var.ssh_key_public | ||
|
|
||
| public_ip_address_name = var.public_ip_address_name | ||
| subnet_id = module.network.subnet_id | ||
| public_ip_id = module.network.public_ip_id | ||
|
|
||
| storage_account_name = module.storage.storage_account_name | ||
| storage_account_key = module.storage.primary_access_key | ||
| script_blob_url = module.storage.script_blob_url | ||
|
|
||
| depends_on = [module.storage] | ||
| } | ||
|
|
||
| module "network" { | ||
| source = "./modules/network" | ||
|
Comment on lines
+33
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checklist Item #9 Violation: The SKU should reference the proper Ubuntu 22.04 identifier. For the |
||
| resource_group_name = azurerm_resource_group.example.name | ||
| location = azurerm_resource_group.example.location | ||
| vnet_address_prefix = var.vnet_address_prefix | ||
| virtual_network_name = var.virtual_network_name | ||
| 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 | ||
| public_ip_allocation_method = "Dynamic" | ||
|
|
||
| } | ||
|
|
||
|
|
||
| module "storage" { | ||
| source = "./modules/storage" | ||
| resource_group_name = var.resource_group_name | ||
| location = var.location | ||
| storage_container_name = var.storage_container_name | ||
| storage_account_key = var.storage_account_key | ||
| storage_account_name = module.storage.storage_account_name | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| resource "azurerm_network_interface" "main" { | ||
| 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_virtual_machine" "main" { | ||
| name = var.vm_name | ||
| location = var.location | ||
| resource_group_name = var.resource_group_name | ||
| network_interface_ids = [ | ||
| azurerm_network_interface.main.id | ||
| ] | ||
| vm_size = var.vm_size | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The storage module receives There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| # Uncomment this line to delete the OS disk automatically when deleting the VM | ||
| # delete_os_disk_on_termination = true | ||
|
|
||
| # Uncomment this line to delete the data disks automatically when deleting the VM | ||
| # delete_data_disks_on_termination = true | ||
|
|
||
| storage_image_reference { | ||
| publisher = "Canonical" | ||
| offer = "0001-com-ubuntu-server-jammy" | ||
|
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| 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" | ||
| } | ||
|
|
||
| os_profile_linux_config { | ||
| disable_password_authentication = true | ||
| ssh_keys { | ||
| key_data = var.ssh_key_public | ||
|
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical Error: |
||
| path = "/home/testadmin/.ssh/authorized_keys" | ||
|
Comment on lines
+50
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical Error: The storage module is passed |
||
| } | ||
| } | ||
|
|
||
| tags = { | ||
| environment = "staging" | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_virtual_machine_extension" "main" { | ||
| name = "install-app" | ||
| virtual_machine_id = azurerm_virtual_machine.main.id | ||
|
|
||
| publisher = "Microsoft.Azure.Extensions" | ||
| type = "CustomScript" | ||
| type_handler_version = "2.1" | ||
|
|
||
| settings = jsonencode({ | ||
| fileUris = [ | ||
| var.script_blob_url | ||
| ] | ||
|
|
||
| commandToExecute = "sudo bash install-app.sh" | ||
| }) | ||
| } | ||
|
|
||
|
|
||
|
|
||
| resource "azurerm_network_interface_security_group_association" "example" { | ||
| network_interface_id = azurerm_network_interface.main.id | ||
| network_security_group_id = var.network_security_group_id | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| output "vm_name" { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| value = azurerm_virtual_machine.main.name | ||
| } | ||
| output "vm_id" { | ||
| value = azurerm_virtual_machine.main.id | ||
| } | ||
| output "network_interface_id" { | ||
| value = azurerm_network_interface.main.id | ||
| } | ||
| output "public_ip_address_name" { | ||
| value = var.public_ip_address_name | ||
| } | ||
| output "nic_id" { | ||
| value = azurerm_network_interface.main.id | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| variable "subnet_id" { | ||
| type = string | ||
| } | ||
| variable "public_ip_id" { | ||
| type = string | ||
| } | ||
| variable "vm_name" { | ||
| type = string | ||
| } | ||
| variable "vm_size" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "resource_group_name" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "location" { | ||
| type = string | ||
| } | ||
|
|
||
|
|
||
| variable "ssh_key_public" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "storage_account_name" { | ||
| type = string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| variable "public_ip_address_name" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "storage_account_key" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "script_blob_url" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "network_security_group_id" { | ||
| description = "Network Security Group ID" | ||
| type = string | ||
| } | ||
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.
Location is 'Korea Central' but requirement specifies 'uksouth' (CHECKLIST ITEM #7).