This is a Terraform provider for Slack
Recommended way
Download and put a binary into plugins directory.
$ export VERSION=<...>
$ curl -sSL "https://raw.githubusercontent.com/jmatsu/terraform-provider-slack/master/scripts/download.sh" | bash
$ mv terraform-provider-slack_$VERSION ~/.terraform.d/plugins/[architecture name]
Or build a binary by yourself.
$ go clone ... && cd /path/to/project
$ go mod download
$ go build .
$ mv terraform-provider-slack ~/.terraform.d/plugins/[architecture name]/
See https://www.terraform.io/docs/configuration/providers.html#third-party-plugins for more details.
- Terraform >= v0.12.0 (v0.11.x may work but not supported actively)
- Scope:
users:read,users:read.email,usergroups:read,usergroups:write,channels:read,channels:write,groups:read,groups:write
ref bot.d/src/bot.tsusers:read.email
is required since v0.6.0
I do not have any Plus or Enterprise Grid workspace which I'm free to use unfortunately.
That's why several resources, e.g. a slack user, have not been supported yet.
provider "slack" {
# A token must be of an user. A bot user's token cannot be used for usergroup api call.
# To get a token, Botkit is one of recommended methods.
token = "SLACK_TOKEN"
}
data "slack_user" "..." {
query_type = "name" or "id" or "email"
query_value = "<name or real name>" or "<user id>" or "<email>"
}
data "slack_conversation" "..." {
channel_id = <channel id>
}
data "slack_usergroup" "..." {
usergroup_id = <usergroup id>
}
resource "slack_conversation" "..." {
name = "<name>"
topic = "..."
purpose = "..."
is_archive = <true|false>
is_private = <true|false>
}
resource "slack_usergroup" "..." {
handle = "<mention name>"
name = "<name>"
description = "..."
auto_type = "" or "admins" or "owners"
}
resource "slack_usergroup_members" "..." {
usergroup_id = "<usergroup id>"
members = ["<user id>", ...]
}
resource "slack_usergroup_channels" "..." {
usergroup_id = "<usergroup id>"
channels = ["<channel id>", ...]
}
$ terraform import slack_conversation.<name> <channel id>
$ terraform import slack_usergroup.<name> <usergroup id>
$ terraform import slack_usergroup_members.<name> <usergroup id>
$ terraform import slack_usergroup_channels.<name> <usergroup id>