1. Packages
  2. Slack Provider
  3. API Docs
  4. Usergroup
Slack v0.4.11 published on Wednesday, Feb 12, 2025 by Pulumi

slack.Usergroup

Explore with Pulumi AI

Manages a Slack User Group.

Required scopes

This resource requires the following scopes:

The Slack API methods used by the resource are:

If you get missing_scope errors while using this resource check the scopes against the documentation for the methods above.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as slack from "@pulumi/slack";

const myGroup = new slack.Usergroup("my_group", {
    name: "TestGroup",
    handle: "test",
    description: "Test user group",
    users: ["USER00"],
    channels: ["CHANNEL00"],
});
Copy
import pulumi
import pulumi_slack as slack

my_group = slack.Usergroup("my_group",
    name="TestGroup",
    handle="test",
    description="Test user group",
    users=["USER00"],
    channels=["CHANNEL00"])
Copy
package main

import (
	"github.com/pulumi/pulumi-slack/sdk/go/slack"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := slack.NewUsergroup(ctx, "my_group", &slack.UsergroupArgs{
			Name:        pulumi.String("TestGroup"),
			Handle:      pulumi.String("test"),
			Description: pulumi.String("Test user group"),
			Users: pulumi.StringArray{
				pulumi.String("USER00"),
			},
			Channels: pulumi.StringArray{
				pulumi.String("CHANNEL00"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Slack = Pulumi.Slack;

return await Deployment.RunAsync(() => 
{
    var myGroup = new Slack.Usergroup("my_group", new()
    {
        Name = "TestGroup",
        Handle = "test",
        Description = "Test user group",
        Users = new[]
        {
            "USER00",
        },
        Channels = new[]
        {
            "CHANNEL00",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.slack.Usergroup;
import com.pulumi.slack.UsergroupArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myGroup = new Usergroup("myGroup", UsergroupArgs.builder()
            .name("TestGroup")
            .handle("test")
            .description("Test user group")
            .users("USER00")
            .channels("CHANNEL00")
            .build());

    }
}
Copy
resources:
  myGroup:
    type: slack:Usergroup
    name: my_group
    properties:
      name: TestGroup
      handle: test
      description: Test user group
      users:
        - USER00
      channels:
        - CHANNEL00
Copy

Note that if a channel is removed from the channels list users are not removed from the channel. In order to keep the users in the groups and in the channel in sync set permanent_users in the channel:

import * as pulumi from "@pulumi/pulumi";
import * as slack from "@pulumi/slack";

const myGroup = new slack.Usergroup("my_group", {
    name: "TestGroup",
    handle: "test",
    description: "Test user group",
    users: ["USER00"],
});
const test = new slack.Conversation("test", {
    name: "my-channel",
    topic: "The topic for my channel",
    permanentMembers: myGroup.users,
    isPrivate: true,
});
Copy
import pulumi
import pulumi_slack as slack

my_group = slack.Usergroup("my_group",
    name="TestGroup",
    handle="test",
    description="Test user group",
    users=["USER00"])
test = slack.Conversation("test",
    name="my-channel",
    topic="The topic for my channel",
    permanent_members=my_group.users,
    is_private=True)
Copy
package main

import (
	"github.com/pulumi/pulumi-slack/sdk/go/slack"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		myGroup, err := slack.NewUsergroup(ctx, "my_group", &slack.UsergroupArgs{
			Name:        pulumi.String("TestGroup"),
			Handle:      pulumi.String("test"),
			Description: pulumi.String("Test user group"),
			Users: pulumi.StringArray{
				pulumi.String("USER00"),
			},
		})
		if err != nil {
			return err
		}
		_, err = slack.NewConversation(ctx, "test", &slack.ConversationArgs{
			Name:             pulumi.String("my-channel"),
			Topic:            pulumi.String("The topic for my channel"),
			PermanentMembers: myGroup.Users,
			IsPrivate:        pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Slack = Pulumi.Slack;

return await Deployment.RunAsync(() => 
{
    var myGroup = new Slack.Usergroup("my_group", new()
    {
        Name = "TestGroup",
        Handle = "test",
        Description = "Test user group",
        Users = new[]
        {
            "USER00",
        },
    });

    var test = new Slack.Conversation("test", new()
    {
        Name = "my-channel",
        Topic = "The topic for my channel",
        PermanentMembers = myGroup.Users,
        IsPrivate = true,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.slack.Usergroup;
import com.pulumi.slack.UsergroupArgs;
import com.pulumi.slack.Conversation;
import com.pulumi.slack.ConversationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myGroup = new Usergroup("myGroup", UsergroupArgs.builder()
            .name("TestGroup")
            .handle("test")
            .description("Test user group")
            .users("USER00")
            .build());

        var test = new Conversation("test", ConversationArgs.builder()
            .name("my-channel")
            .topic("The topic for my channel")
            .permanentMembers(myGroup.users())
            .isPrivate(true)
            .build());

    }
}
Copy
resources:
  myGroup:
    type: slack:Usergroup
    name: my_group
    properties:
      name: TestGroup
      handle: test
      description: Test user group
      users:
        - USER00
  test:
    type: slack:Conversation
    properties:
      name: my-channel
      topic: The topic for my channel
      permanentMembers: ${myGroup.users}
      isPrivate: true
Copy

Create Usergroup Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Usergroup(name: string, args?: UsergroupArgs, opts?: CustomResourceOptions);
@overload
def Usergroup(resource_name: str,
              args: Optional[UsergroupArgs] = None,
              opts: Optional[ResourceOptions] = None)

@overload
def Usergroup(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              channels: Optional[Sequence[str]] = None,
              description: Optional[str] = None,
              handle: Optional[str] = None,
              name: Optional[str] = None,
              users: Optional[Sequence[str]] = None)
func NewUsergroup(ctx *Context, name string, args *UsergroupArgs, opts ...ResourceOption) (*Usergroup, error)
public Usergroup(string name, UsergroupArgs? args = null, CustomResourceOptions? opts = null)
public Usergroup(String name, UsergroupArgs args)
public Usergroup(String name, UsergroupArgs args, CustomResourceOptions options)
type: slack:Usergroup
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args UsergroupArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args UsergroupArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args UsergroupArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args UsergroupArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. UsergroupArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var usergroupResource = new Slack.Usergroup("usergroupResource", new()
{
    Channels = new[]
    {
        "string",
    },
    Description = "string",
    Handle = "string",
    Name = "string",
    Users = new[]
    {
        "string",
    },
});
Copy
example, err := slack.NewUsergroup(ctx, "usergroupResource", &slack.UsergroupArgs{
	Channels: pulumi.StringArray{
		pulumi.String("string"),
	},
	Description: pulumi.String("string"),
	Handle:      pulumi.String("string"),
	Name:        pulumi.String("string"),
	Users: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var usergroupResource = new Usergroup("usergroupResource", UsergroupArgs.builder()
    .channels("string")
    .description("string")
    .handle("string")
    .name("string")
    .users("string")
    .build());
Copy
usergroup_resource = slack.Usergroup("usergroupResource",
    channels=["string"],
    description="string",
    handle="string",
    name="string",
    users=["string"])
Copy
const usergroupResource = new slack.Usergroup("usergroupResource", {
    channels: ["string"],
    description: "string",
    handle: "string",
    name: "string",
    users: ["string"],
});
Copy
type: slack:Usergroup
properties:
    channels:
        - string
    description: string
    handle: string
    name: string
    users:
        - string
Copy

Usergroup Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Usergroup resource accepts the following input properties:

Channels List<string>
channel IDs for which the User Group uses as a default.
Description string
a short description of the User Group.
Handle string
a mention handle. Must be unique among channels, users and User Groups.
Name string
a name for the User Group. Must be unique among User Groups.
Users List<string>
user IDs that represent the entire list of users for the User Group.
Channels []string
channel IDs for which the User Group uses as a default.
Description string
a short description of the User Group.
Handle string
a mention handle. Must be unique among channels, users and User Groups.
Name string
a name for the User Group. Must be unique among User Groups.
Users []string
user IDs that represent the entire list of users for the User Group.
channels List<String>
channel IDs for which the User Group uses as a default.
description String
a short description of the User Group.
handle String
a mention handle. Must be unique among channels, users and User Groups.
name String
a name for the User Group. Must be unique among User Groups.
users List<String>
user IDs that represent the entire list of users for the User Group.
channels string[]
channel IDs for which the User Group uses as a default.
description string
a short description of the User Group.
handle string
a mention handle. Must be unique among channels, users and User Groups.
name string
a name for the User Group. Must be unique among User Groups.
users string[]
user IDs that represent the entire list of users for the User Group.
channels Sequence[str]
channel IDs for which the User Group uses as a default.
description str
a short description of the User Group.
handle str
a mention handle. Must be unique among channels, users and User Groups.
name str
a name for the User Group. Must be unique among User Groups.
users Sequence[str]
user IDs that represent the entire list of users for the User Group.
channels List<String>
channel IDs for which the User Group uses as a default.
description String
a short description of the User Group.
handle String
a mention handle. Must be unique among channels, users and User Groups.
name String
a name for the User Group. Must be unique among User Groups.
users List<String>
user IDs that represent the entire list of users for the User Group.

Outputs

All input properties are implicitly available as output properties. Additionally, the Usergroup resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Usergroup Resource

Get an existing Usergroup resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: UsergroupState, opts?: CustomResourceOptions): Usergroup
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        channels: Optional[Sequence[str]] = None,
        description: Optional[str] = None,
        handle: Optional[str] = None,
        name: Optional[str] = None,
        users: Optional[Sequence[str]] = None) -> Usergroup
func GetUsergroup(ctx *Context, name string, id IDInput, state *UsergroupState, opts ...ResourceOption) (*Usergroup, error)
public static Usergroup Get(string name, Input<string> id, UsergroupState? state, CustomResourceOptions? opts = null)
public static Usergroup get(String name, Output<String> id, UsergroupState state, CustomResourceOptions options)
resources:  _:    type: slack:Usergroup    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Channels List<string>
channel IDs for which the User Group uses as a default.
Description string
a short description of the User Group.
Handle string
a mention handle. Must be unique among channels, users and User Groups.
Name string
a name for the User Group. Must be unique among User Groups.
Users List<string>
user IDs that represent the entire list of users for the User Group.
Channels []string
channel IDs for which the User Group uses as a default.
Description string
a short description of the User Group.
Handle string
a mention handle. Must be unique among channels, users and User Groups.
Name string
a name for the User Group. Must be unique among User Groups.
Users []string
user IDs that represent the entire list of users for the User Group.
channels List<String>
channel IDs for which the User Group uses as a default.
description String
a short description of the User Group.
handle String
a mention handle. Must be unique among channels, users and User Groups.
name String
a name for the User Group. Must be unique among User Groups.
users List<String>
user IDs that represent the entire list of users for the User Group.
channels string[]
channel IDs for which the User Group uses as a default.
description string
a short description of the User Group.
handle string
a mention handle. Must be unique among channels, users and User Groups.
name string
a name for the User Group. Must be unique among User Groups.
users string[]
user IDs that represent the entire list of users for the User Group.
channels Sequence[str]
channel IDs for which the User Group uses as a default.
description str
a short description of the User Group.
handle str
a mention handle. Must be unique among channels, users and User Groups.
name str
a name for the User Group. Must be unique among User Groups.
users Sequence[str]
user IDs that represent the entire list of users for the User Group.
channels List<String>
channel IDs for which the User Group uses as a default.
description String
a short description of the User Group.
handle String
a mention handle. Must be unique among channels, users and User Groups.
name String
a name for the User Group. Must be unique among User Groups.
users List<String>
user IDs that represent the entire list of users for the User Group.

Import

slack_usergroup can be imported using the ID of the group, e.g.

$ pulumi import slack:index/usergroup:Usergroup my_group S022GE79E9G
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
slack pulumi/pulumi-slack
License
Apache-2.0
Notes
This Pulumi package is based on the slack Terraform Provider.