Token cannot be an empty string (Terraform +

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 After doing terraform apply and adding the next part of, 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 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"
    MEMORY                  = "7G"

  services = [
      ports = [
          port = 25565
      protocol      = "tcp"
      internal_port = 25565

  mounts = [
    { path   = "/data"
      volume =

  cpus     = 4
  memorymb = 8192

  depends_on = [fly_volume.mcVolume, fly_app.minecraft]

Can you try setting your FLY_API_TOKEN again? Then terraform apply

export FLY_API_TOKEN=$(flyctl auth token)
terraform apply

I tried that command, looks like I’m still getting the same error.

Interesting, do you get any error when running flyctl auth token ( do not paste output :).

Nope, no errors. The command runs, then it’s ready for the next prompt.

Just found out the issue: I was installing flyctl and signing in successfully, but it wasn’t properly installed. Using the commands given after the install wasn’t working either, so I ended up installing as root and that solved the issue.

It seems that now I’m stuck on the step where I create the fly_machine.mcServer, where it tells me that I can’t connect to the api. I also used the flyctl machine api-proxy command, which only tells me the selected organization before moving no further.

flyctl machine api-proxy
automatically selected personal organization: Petra Mubata

Is there supposed to be input after this, or is it supposed to stop?

Forgot to post, but if I log out and log back in multiple times, that fixes the error. Thanks for the help!