terraform-iaas-api-example/030-server.tf
Mauritz Uphoff 78961a6349
Some checks failed
CI / Terraform Format & Validate (push) Failing after 8s
CI / TruffleHog Secrets Scan (push) Successful in 7s
order h100 gpu
2025-06-26 15:53:16 +02:00

49 lines
No EOL
1.5 KiB
HCL

provider "stackit" {
default_region = var.stackit_region
service_account_key_path = var.stackit_service_account_key_path
}
resource "stackit_key_pair" "example_keypair" {
name = "example-keypair"
public_key = chomp(file("~/.ssh/id_rsa.pub"))
}
resource "stackit_network_interface" "example_nic" {
project_id = var.stackit_project_id
network_id = stackit_network.example_network.network_id
security = false
}
resource "stackit_server" "example_server" {
project_id = var.stackit_project_id
name = "example-server"
boot_volume = {
size = 64
source_type = "image"
source_id = "a2c127b2-b1b5-4aee-986f-41cd11b41279" // ubuntu 24.04
performance_class = "storage_premium_perf12"
}
availability_zone = "eu01-2"
// change on the machine type does not affect the underlying volume
machine_type = "n3.56d.g4"
keypair_name = stackit_key_pair.example_keypair.name
network_interfaces = [
stackit_network_interface.example_nic.network_interface_id
]
}
resource "stackit_network" "example_network" {
project_id = var.stackit_project_id
name = "example-network"
ipv4_prefix_length = 24
ipv4_nameservers = ["1.1.1.1", "8.8.8.8"]
}
resource "stackit_public_ip" "example_public_ip" {
project_id = var.stackit_project_id
network_interface_id = stackit_network_interface.example_nic.network_interface_id
}
output "public_ip" {
value = stackit_public_ip.example_public_ip.ip
}