Not sure if anyone else has this problem, but I went to follow the tutorial here because it seemed pretty simple. However, I seem to be hitting a wall with the main.tf. After doing terraform apply and adding the next part of main.tf, I get an error telling me that the token cannot be an empty string. It wasn’t an issue before I added the rest of the code either.
I tried checking the documentation and adding an argument for FLY_API_TOKEN, but that doesn’t seem to work, either. Any ideas? I’m fairly new to this so it’s been a bit of a struggle.
My main.tf file:
terraform {
required_providers {
fly = {
source = "fly-apps/fly"
version = "0.0.16"
}
}
}
provider "fly" {}
resource "fly_app" "minecraft" {
name = "flymcapp"
org = "personal"
}
resource "fly_volume" "mcVolume" {
app = "flymcapp"
name = "mcVolume"
size = 15
region = "yyz"
depends_on = [fly_app.minecraft]
}
resource "fly_ip" "mcIP" {
app = "flymcapp"
type = "v4"
depends_on = [fly_app.minecraft]
}
resource "fly_machine" "mcServer" {
name = "mc-server"
region = "yyz"
app = "flymcapp"
image = "itzg/minecraft-server:latest"
env = {
EULA = "TRUE"
ENABLE_AUTOSTOP = "TRUE"
AUTOSTOP_TIMEOUT_EST = 120
AUTOSTOP_TIMEOUT_INIT = 120
MEMORY = "7G"
AUTOSTOP_PKILL_USE_SUDO = "TRUE"
}
services = [
{
ports = [
{
port = 25565
}
]
protocol = "tcp"
internal_port = 25565
}
]
mounts = [
{ path = "/data"
volume = fly_volume.mcVolume.id
}
]
cpus = 4
memorymb = 8192
depends_on = [fly_volume.mcVolume, fly_app.minecraft]
}