Created
December 8, 2019 23:03
-
-
Save ossentoo/ada3b675a057718541c21b7e3590426e to your computer and use it in GitHub Desktop.
This file contains 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
resource "azurerm_resource_group" "test" { | |
name = "terraform-testing" | |
location = "South Central US" | |
} | |
resource "azurerm_virtual_network" "test" { | |
name = "acctvn" | |
address_space = ["10.0.5.0/24"] | |
location = azurerm_resource_group.test.location | |
resource_group_name = azurerm_resource_group.test.name | |
} | |
resource "azurerm_subnet" "test" { | |
name = "acctsub" | |
resource_group_name = azurerm_resource_group.test.name | |
virtual_network_name = azurerm_virtual_network.test.name | |
address_prefix = "10.0.5.0/24" | |
} | |
resource "azurerm_public_ip" "test" { | |
name = "acctpip" | |
location = azurerm_resource_group.test.location | |
resource_group_name = azurerm_resource_group.test.name | |
allocation_method = "Static" | |
} | |
resource "azurerm_lb" "test" { | |
name = "test-lb" | |
location = azurerm_resource_group.test.location | |
resource_group_name = azurerm_resource_group.test.name | |
frontend_ip_configuration { | |
name = "pip-config" | |
public_ip_address_id = azurerm_public_ip.test.id | |
} | |
} | |
resource "azurerm_lb_backend_address_pool" "test" { | |
resource_group_name = azurerm_resource_group.test.name | |
loadbalancer_id = azurerm_lb.test.id | |
name = "backend-ap" | |
} | |
resource "azurerm_lb_nat_pool" "test" { | |
resource_group_name = azurerm_resource_group.test.name | |
name = "ssh" | |
loadbalancer_id = azurerm_lb.test.id | |
protocol = "Tcp" | |
frontend_port_start = 50000 | |
frontend_port_end = 50099 | |
backend_port = 22 | |
frontend_ip_configuration_name = "pip-config" | |
} | |
resource "azurerm_virtual_machine_scale_set" "managers_vmss" { | |
name = "test-vmss" | |
location = azurerm_resource_group.test.location | |
resource_group_name = azurerm_resource_group.test.name | |
upgrade_policy_mode = "Manual" | |
overprovision = false | |
sku { | |
name = "Standard_A0" | |
tier = "Standard" | |
capacity = 2 | |
} | |
storage_profile_image_reference { | |
publisher = "Canonical" | |
offer = "UbuntuServer" | |
sku = "16.04-LTS" | |
version = "latest" | |
} | |
storage_profile_os_disk { | |
name = "" | |
caching = "ReadWrite" | |
create_option = "FromImage" | |
managed_disk_type = "Standard_LRS" | |
} | |
storage_profile_data_disk { | |
lun = 0 | |
caching = "ReadWrite" | |
create_option = "Empty" | |
disk_size_gb = 50 | |
} | |
os_profile { | |
admin_username = var.vm_user | |
admin_password = var.vm_pass | |
computer_name_prefix = "terraformtest" | |
} | |
os_profile_linux_config { | |
disable_password_authentication = true | |
ssh_keys { | |
path = "/home/admin/.ssh/authorized_keys" | |
key_data = file("~/.ssh/id_rsa.pub") | |
} | |
} | |
network_profile { | |
name = "terraform-network-profile" | |
primary = true | |
ip_configuration { | |
name = "test-ip-config" | |
primary = true | |
subnet_id = azurerm_subnet.test.id | |
load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.test.id] | |
load_balancer_inbound_nat_rules_ids = ["azurerm_lb_nat_pool.test.*.id"] | |
} | |
} | |
connection { | |
type = "ssh" | |
host = azurerm_public_ip.test.ip_address | |
user = var.vm_user | |
private_key = file("id_rsa") | |
##Here's my issue: | |
port = format("5000%d", count.index) | |
} | |
} | |
variable "vm_user" { | |
default = "admin" | |
type = string | |
} | |
variable "vm_pass" { | |
default = "thisP@55word989876" | |
type = string | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment