2022-12-14 10:51:42 -05:00
|
|
|
terraform {
|
|
|
|
required_providers {
|
|
|
|
azurerm = {
|
|
|
|
source = "hashicorp/azurerm"
|
2023-09-26 07:17:17 -04:00
|
|
|
version = "3.74.0"
|
2022-12-14 10:51:42 -05:00
|
|
|
}
|
|
|
|
random = {
|
|
|
|
source = "hashicorp/random"
|
2023-05-16 10:01:47 -04:00
|
|
|
version = "3.5.1"
|
2022-12-14 10:51:42 -05:00
|
|
|
}
|
|
|
|
tls = {
|
|
|
|
source = "hashicorp/tls"
|
|
|
|
version = "4.0.4"
|
|
|
|
}
|
2023-03-22 09:54:46 -04:00
|
|
|
cloudinit = {
|
|
|
|
source = "hashicorp/cloudinit"
|
|
|
|
version = "2.3.2"
|
|
|
|
}
|
2022-12-14 10:51:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "azurerm" {
|
|
|
|
use_oidc = true
|
|
|
|
features {}
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "tls" {}
|
|
|
|
|
|
|
|
resource "random_string" "suffix" {
|
|
|
|
length = 6
|
|
|
|
special = false
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "tls_private_key" "ssh_key" {
|
|
|
|
algorithm = "RSA"
|
|
|
|
rsa_bits = 2048
|
|
|
|
}
|
|
|
|
|
2023-03-22 09:54:46 -04:00
|
|
|
data "cloudinit_config" "cloud_init" {
|
|
|
|
base64_encode = true
|
|
|
|
part {
|
|
|
|
filename = "cloud-init.yaml"
|
|
|
|
content_type = "text/cloud-config"
|
|
|
|
|
|
|
|
content = file("${path.module}/cloud-init.yaml")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-14 10:51:42 -05:00
|
|
|
data "azurerm_resource_group" "main" {
|
|
|
|
name = "e2e-miniconstellation"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_virtual_network" "main" {
|
|
|
|
name = "e2e-mini-${random_string.suffix.result}"
|
|
|
|
address_space = ["10.0.0.0/16"]
|
|
|
|
location = data.azurerm_resource_group.main.location
|
|
|
|
resource_group_name = data.azurerm_resource_group.main.name
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_subnet" "main" {
|
|
|
|
name = "e2e-mini-${random_string.suffix.result}"
|
|
|
|
resource_group_name = data.azurerm_resource_group.main.name
|
|
|
|
virtual_network_name = azurerm_virtual_network.main.name
|
|
|
|
address_prefixes = ["10.0.2.0/24"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_public_ip" "main" {
|
|
|
|
name = "e2e-mini-${random_string.suffix.result}"
|
|
|
|
location = data.azurerm_resource_group.main.location
|
|
|
|
resource_group_name = data.azurerm_resource_group.main.name
|
|
|
|
allocation_method = "Static"
|
|
|
|
sku = "Standard"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_network_interface" "main" {
|
|
|
|
name = "e2e-mini-${random_string.suffix.result}"
|
|
|
|
resource_group_name = data.azurerm_resource_group.main.name
|
|
|
|
location = data.azurerm_resource_group.main.location
|
|
|
|
|
|
|
|
ip_configuration {
|
|
|
|
name = "main"
|
|
|
|
subnet_id = azurerm_subnet.main.id
|
|
|
|
private_ip_address_allocation = "Dynamic"
|
|
|
|
public_ip_address_id = azurerm_public_ip.main.id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_network_security_group" "ssh" {
|
|
|
|
name = "e2e-mini-${random_string.suffix.result}"
|
|
|
|
resource_group_name = data.azurerm_resource_group.main.name
|
|
|
|
location = data.azurerm_resource_group.main.location
|
|
|
|
|
|
|
|
security_rule {
|
|
|
|
name = "ssh"
|
|
|
|
priority = 100
|
|
|
|
direction = "Inbound"
|
|
|
|
access = "Allow"
|
|
|
|
protocol = "Tcp"
|
|
|
|
source_port_range = "*"
|
|
|
|
destination_port_range = "22"
|
|
|
|
source_address_prefix = "*"
|
|
|
|
destination_address_prefix = "*"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_subnet_network_security_group_association" "ssh" {
|
|
|
|
subnet_id = azurerm_subnet.main.id
|
|
|
|
network_security_group_id = azurerm_network_security_group.ssh.id
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "azurerm_linux_virtual_machine" "main" {
|
|
|
|
name = "e2e-mini-${random_string.suffix.result}"
|
|
|
|
resource_group_name = data.azurerm_resource_group.main.name
|
|
|
|
location = data.azurerm_resource_group.main.location
|
2023-03-22 09:54:46 -04:00
|
|
|
|
2023-03-31 06:41:32 -04:00
|
|
|
# Standard_D8s_v5 provides nested virtualization support
|
|
|
|
size = "Standard_D8s_v5"
|
2023-03-22 09:54:46 -04:00
|
|
|
|
2022-12-14 10:51:42 -05:00
|
|
|
admin_username = "adminuser"
|
|
|
|
|
|
|
|
admin_ssh_key {
|
|
|
|
username = "adminuser"
|
|
|
|
public_key = tls_private_key.ssh_key.public_key_openssh
|
|
|
|
}
|
|
|
|
|
2023-03-31 06:41:32 -04:00
|
|
|
boot_diagnostics {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-03-22 09:54:46 -04:00
|
|
|
network_interface_ids = [
|
|
|
|
azurerm_network_interface.main.id,
|
|
|
|
]
|
|
|
|
|
2022-12-14 10:51:42 -05:00
|
|
|
source_image_reference {
|
|
|
|
publisher = "Canonical"
|
|
|
|
offer = "0001-com-ubuntu-server-jammy-daily"
|
|
|
|
sku = "22_04-daily-lts"
|
|
|
|
version = "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
os_disk {
|
|
|
|
storage_account_type = "Standard_LRS"
|
|
|
|
caching = "ReadWrite"
|
|
|
|
}
|
2023-03-22 09:54:46 -04:00
|
|
|
|
|
|
|
user_data = data.cloudinit_config.cloud_init.rendered
|
2022-12-14 10:51:42 -05:00
|
|
|
}
|