Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managing discord_member_roles #14

Open
Warfront1 opened this issue Feb 25, 2022 · 2 comments
Open

Managing discord_member_roles #14

Warfront1 opened this issue Feb 25, 2022 · 2 comments

Comments

@Warfront1
Copy link

Warfront1 commented Feb 25, 2022

When trying to reference a user_id in a discord_member_roles, there seems to be no handling for discord_members that are not part of the discord server?

Sample terraform:

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

terraform {
  required_version = ">= 0.13"
}

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

provider discord {
  token = var.discord_token
}

resource discord_server my_server {
  name = "test"
  default_message_notifications = 0
}

data discord_permission serveradmin {
  administrator = "allow"
}

resource discord_role serveradmin {
  server_id = discord_server.my_server.id
  name = "Server Admin"
  permissions = data.discord_permission.serveradmin.allow_bits
  position = 0
}

resource discord_member_roles warfront1 {
  user_id = "1234"
  server_id = discord_server.my_server.id
  role {
    role_id = discord_role.serveradmin.id
  }
}

Ouput:

Error: Could not get member 1234 in 123456: Unknown Member
{"message": "Unknown Member", "code": 10007}
GET:/guilds/123456/members/{id} => []

This becomes problematic especially when first creating your discord server, as you can't assign roles prior to having a member join the newly created server.
In addition, your apply could easily break if the user you are attempting to modify a role for leaves the server themselves.

@tigattack
Copy link

You can't add members to a role when they aren't in the server.

Imagine you're setting file permissions, what do you think would happen if you tried to set the owner of a file to a user that doesn't exist?

@Warfront1
Copy link
Author

Warfront1 commented Aug 3, 2022

You can't add members to a role when they aren't in the server.

Imagine you're setting file permissions, what do you think would happen if you tried to set the owner of a file to a user that doesn't exist?

To answer your question, the user creation would scripted out, and set as a dependency of the file permission.

The use case I provided is very common, and causes for a very broken terraform automation process.
At the very least, I am looking for the intended guidance on what to do in such a situation.

For example, is the recommendation that you:

  • Run your terraform once to create the server, creating the core server component, but bombing/failing all user specific configurations
    • This would even be relevant for yourself specifically, as you have not joined the server yet.
  • Then have each of the users that need configuration join (manually invite, ask to them join; could take days)
  • Make sure everyone is accounted for (manually take account)
  • Re-run the terraform hoping all was accounted for

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants