dotfiles/hosts/arrow/vultr/main.tf

79 lines
2.0 KiB
Terraform
Raw Permalink Normal View History

2024-03-24 17:16:20 +00:00
terraform {
2024-03-24 18:36:23 +00:00
backend "s3" {
bucket = "noahmasur-terraform"
key = "arrow.tfstate"
region = "auto"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
skip_requesting_account_id = true
skip_s3_checksum = true
use_path_style = true
/*
ENVIRONMENT VARIABLES
---------------------
AWS_ACCESS_KEY_ID - R2 token
AWS_SECRET_ACCESS_KEY - R2 secret
AWS_ENDPOINT_URL_S3 - R2 location: https://ACCOUNT_ID.r2.cloudflarestorage.com
*/
}
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"
}
}
}
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
}
2024-03-30 18:30:02 +00:00
# https://api.vultr.com/v2/plans
variable "vultr_plan" {
type = string
description = "Size of instance to launch"
default = "vc2-1c-2gb" # 55 GB SSD ($10/mo)
}
2024-03-24 17:16:20 +00:00
provider "aws" {
2024-03-24 18:39:18 +00:00
region = "auto"
2024-03-24 17:16:20 +00:00
skip_credentials_validation = true
2024-03-24 18:39:18 +00:00
skip_metadata_api_check = true
2024-03-24 17:16:20 +00:00
skip_region_validation = true
skip_requesting_account_id = true
}
provider "vultr" {
api_key = var.vultr_api_key
}
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-30 18:30:02 +00:00
plan = var.vultr_plan
2024-03-24 17:59:36 +00:00
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
}