54 lines
1.1 KiB
HCL
54 lines
1.1 KiB
HCL
# A site in one go: a VPS, a domain and the records that point the domain to the VPS.
|
|
# Run it first with a sandbox_ key: everything is simulated and nothing is charged.
|
|
|
|
terraform {
|
|
required_providers {
|
|
mozout = {
|
|
source = "mozout-com/mozout"
|
|
version = "~> 1.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
provider "mozout" {}
|
|
|
|
variable "domain" {
|
|
type = string
|
|
default = "example.com"
|
|
}
|
|
|
|
data "mozout_catalog_products" "vps" {
|
|
kind = "vps"
|
|
}
|
|
|
|
resource "mozout_vps" "web" {
|
|
product_id = data.mozout_catalog_products.vps.products[0].id
|
|
billing_cycle = "monthly"
|
|
power_state = "running"
|
|
}
|
|
|
|
resource "mozout_domain" "site" {
|
|
domain = var.domain
|
|
locked = true
|
|
auto_renew = true
|
|
}
|
|
|
|
resource "mozout_dns_record" "root" {
|
|
domain = mozout_domain.site.domain
|
|
name = "@"
|
|
type = "A"
|
|
value = coalesce(mozout_vps.web.ip, "203.0.113.10")
|
|
ttl = 3600
|
|
}
|
|
|
|
resource "mozout_dns_record" "www" {
|
|
domain = mozout_domain.site.domain
|
|
name = "www"
|
|
type = "CNAME"
|
|
value = var.domain
|
|
ttl = 3600
|
|
}
|
|
|
|
output "server_ip" {
|
|
value = mozout_vps.web.ip
|
|
}
|