Getting Started with Terraform
This guide stands up a minimal Frostmoln configuration with Terraform.
1. Configure the provider
Create main.tf:
hcl
terraform {
required_providers {
frostmoln = {
source = "frostmoln/frostmoln"
}
}
}
provider "frostmoln" {
# Credentials are read from provider arguments or environment variables.
# Generate an API key in the portal under Settings -> API Keys.
}Provide your API key via the environment so it stays out of source control:
bash
export FROSTMOLN_API_KEY=fmk_...2. Define resources
hcl
resource "frostmoln_network_vpc" "main" {
name = "tf-vpc"
region = "sweden"
cidr = "10.0.0.0/16"
}
resource "frostmoln_compute_instance" "web" {
name = "tf-web"
region = "sweden"
image = "ubuntu-24.04"
flavor = "c1.small"
vpc = frostmoln_network_vpc.main.id
ssh_key = "my-laptop"
}3. Apply
bash
terraform init
terraform plan
terraform applyTerraform tracks state, so subsequent apply runs only change what differs. terraform destroy tears the resources back down.