cryptiklemur / terraform-provider-discord

Discord Provider for Terraform
GNU General Public License v3.0
42 stars 33 forks source link

Can almost get a server working, but not quite #2

Open webcoyote opened 4 years ago

webcoyote commented 4 years ago

I'm endeavoring to create a server using Terraform and your library, and while everything runs, and (apparently) a server is created, I'm not able to see any text channels, and get this error:

No Text Channels
You find yourself in a strange place. You don't have access to any text channels, or there are none in this server.

Here's the code:

variable "discord_token" {
  description = "Discord token"
  type        = string
  default     = "<SECRET TOKEN GOES HERE>"
}

terraform {
  required_version = ">= 0.13"
}

locals {
  server_name = "Test Site"
  region = "us-west"
}

terraform {
  required_providers {
    discord = {
      source = "aequasi/discord"
      version = "0.0.4"
    }
  }
}

provider discord {
  token = var.discord_token
}

resource discord_server my_server {
  name = local.server_name
  region = local.region
  default_message_notifications = 0
}

resource discord_category_channel public {
  name = "public"
  position = 0
  server_id = discord_server.my_server.id
}

resource discord_text_channel welcome {
  name = "welcome"
  topic = "The welcome channel"
  position = 0
  category = discord_category_channel.public.id
  server_id = discord_server.my_server.id
}

data discord_permission member {
  view_channel     = "allow"
  send_messages    = "allow"
}

resource discord_role_everyone everyone {
  permissions = data.discord_permission.member.allow_bits
  server_id = discord_server.my_server.id
}

And the result:

terraform apply --auto-approve
data.discord_permission.member: Refreshing state... [id=3681448725]
discord_server.my_server: Refreshing state... [id=753831833946292296]
discord_category_channel.public: Refreshing state... [id=753831838853627925]
discord_role_everyone.everyone: Refreshing state... [id=753831833946292296]
discord_text_channel.welcome: Refreshing state... [id=753831840258719744]
discord_channel_permission.public: Refreshing state... [id=2655848062]

Any suggestions? And thanks. I hope that a simple example like the code above might help other folks get things working too.

webcoyote commented 3 years ago

Found the solution. For future readers, it turns out that you need to invite yourself to the server:

resource discord_invite welcome {
    channel_id = discord_text_channel.welcome.id
    max_age = 0
}

output invite {
  value = "https://discord.gg/${discord_invite.welcome.id}"
}

Open the link to add yourself to the server.