mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
5cfa91f3db
Co-authored-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
148 lines
3.8 KiB
HCL
148 lines
3.8 KiB
HCL
terraform {
|
|
required_providers {
|
|
azurerm = {
|
|
source = "hashicorp/azurerm"
|
|
version = "3.74.0"
|
|
}
|
|
random = {
|
|
source = "hashicorp/random"
|
|
version = "3.5.1"
|
|
}
|
|
tls = {
|
|
source = "hashicorp/tls"
|
|
version = "4.0.4"
|
|
}
|
|
cloudinit = {
|
|
source = "hashicorp/cloudinit"
|
|
version = "2.3.2"
|
|
}
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|
|
|
|
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
|
|
|
|
# Standard_D8s_v5 provides nested virtualization support
|
|
size = "Standard_D8s_v5"
|
|
|
|
admin_username = "adminuser"
|
|
|
|
admin_ssh_key {
|
|
username = "adminuser"
|
|
public_key = tls_private_key.ssh_key.public_key_openssh
|
|
}
|
|
|
|
boot_diagnostics {
|
|
|
|
}
|
|
|
|
network_interface_ids = [
|
|
azurerm_network_interface.main.id,
|
|
]
|
|
|
|
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"
|
|
}
|
|
|
|
user_data = data.cloudinit_config.cloud_init.rendered
|
|
}
|