2024-03-24 17:16:20 +00:00
|
|
|
terraform {
|
2024-03-24 17:59:36 +00:00
|
|
|
backend "s3" {}
|
2024-03-24 17:16:20 +00:00
|
|
|
required_version = ">= 1.0.0"
|
|
|
|
required_providers {
|
|
|
|
aws = {
|
2024-03-24 17:59:36 +00:00
|
|
|
source = "hashicorp/aws"
|
2024-03-24 17:16:20 +00:00
|
|
|
version = "5.42.0"
|
|
|
|
}
|
|
|
|
vultr = {
|
2024-03-24 17:59:36 +00:00
|
|
|
source = "vultr/vultr"
|
2024-03-24 17:16:20 +00:00
|
|
|
version = "2.19.0"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# locals {
|
|
|
|
# image_file = one(fileset(path.root, "result/iso/nixos.iso"))
|
|
|
|
# }
|
|
|
|
|
2024-03-24 18:29:51 +00:00
|
|
|
variable "cloudflare_r2_endpoint" {
|
2024-03-24 17:59:36 +00:00
|
|
|
type = string
|
2024-03-24 18:29:51 +00:00
|
|
|
description = "Domain for the Cloudflare R2 endpoint"
|
2024-03-24 17:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
variable "vultr_api_key" {
|
2024-03-24 17:59:36 +00:00
|
|
|
type = string
|
|
|
|
description = "API key for Vultr management"
|
|
|
|
sensitive = true
|
2024-03-24 17:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
provider "aws" {
|
|
|
|
region = "us-east-1"
|
|
|
|
|
|
|
|
skip_credentials_validation = true
|
|
|
|
skip_region_validation = true
|
|
|
|
skip_requesting_account_id = true
|
|
|
|
|
|
|
|
endpoints {
|
2024-03-24 18:29:51 +00:00
|
|
|
s3 = "https://${var.cloudflare_r2_endpoint}"
|
2024-03-24 17:16:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
provider "vultr" {
|
|
|
|
api_key = var.vultr_api_key
|
|
|
|
}
|
|
|
|
|
|
|
|
# data "aws_s3_bucket" "images" {
|
|
|
|
# bucket = "noahmasur-arrow-images"
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# resource "aws_s3_object" "image" {
|
|
|
|
# bucket = data.aws_s3_bucket.images.id
|
|
|
|
# key = "arrow.iso"
|
|
|
|
# source = local.image_file
|
|
|
|
# etag = filemd5(local.image_file)
|
|
|
|
# acl = "public-read"
|
|
|
|
# }
|
|
|
|
|
|
|
|
resource "vultr_iso_private" "image" {
|
2024-03-24 17:59:36 +00:00
|
|
|
# url = "https://${var.cloudflare_account_id}.r2.cloudflarestorage.com/${data.aws_s3_bucket.images.id}/${aws_s3_object.image.key}"
|
|
|
|
url = "https://arrow.images.masu.rs/arrow.iso"
|
2024-03-24 17:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "vultr_instance" "arrow" {
|
2024-03-24 17:59:36 +00:00
|
|
|
plan = "vc2-1c-2gb"
|
|
|
|
region = "ewr"
|
|
|
|
iso_id = vultr_iso_private.image.id
|
|
|
|
label = "arrow"
|
|
|
|
tags = ["arrow"]
|
|
|
|
enable_ipv6 = false
|
|
|
|
disable_public_ipv4 = false
|
|
|
|
backups = "disabled"
|
|
|
|
ddos_protection = false
|
|
|
|
activation_email = false
|
2024-03-24 17:16:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
output "host_ip" {
|
2024-03-24 17:59:36 +00:00
|
|
|
value = vultr_instance.arrow.main_ip
|
2024-03-24 17:16:20 +00:00
|
|
|
}
|