1. Packages
  2. Harness Provider
  3. API Docs
  4. AddUserToGroup
Harness v0.7.3 published on Friday, Apr 18, 2025 by Pulumi

harness.AddUserToGroup

Explore with Pulumi AI

Resource for adding a user to a group.

Example Usage

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

const exampleUser = harness.getUser({
    email: "testuser@example.com",
});
const admin = new harness.UserGroup("admin", {name: "admin"});
const exampleAddUserToGroups = new harness.AddUserToGroup("example_add_user_to_groups", {
    groupId: admin.id,
    userId: test.id,
});
Copy
import pulumi
import pulumi_harness as harness

example_user = harness.get_user(email="testuser@example.com")
admin = harness.UserGroup("admin", name="admin")
example_add_user_to_groups = harness.AddUserToGroup("example_add_user_to_groups",
    group_id=admin.id,
    user_id=test["id"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := harness.LookupUser(ctx, &harness.LookupUserArgs{
			Email: pulumi.StringRef("testuser@example.com"),
		}, nil)
		if err != nil {
			return err
		}
		admin, err := harness.NewUserGroup(ctx, "admin", &harness.UserGroupArgs{
			Name: pulumi.String("admin"),
		})
		if err != nil {
			return err
		}
		_, err = harness.NewAddUserToGroup(ctx, "example_add_user_to_groups", &harness.AddUserToGroupArgs{
			GroupId: admin.ID(),
			UserId:  pulumi.Any(test.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Harness = Pulumi.Harness;

return await Deployment.RunAsync(() => 
{
    var exampleUser = Harness.GetUser.Invoke(new()
    {
        Email = "testuser@example.com",
    });

    var admin = new Harness.UserGroup("admin", new()
    {
        Name = "admin",
    });

    var exampleAddUserToGroups = new Harness.AddUserToGroup("example_add_user_to_groups", new()
    {
        GroupId = admin.Id,
        UserId = test.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.harness.HarnessFunctions;
import com.pulumi.harness.inputs.GetUserArgs;
import com.pulumi.harness.UserGroup;
import com.pulumi.harness.UserGroupArgs;
import com.pulumi.harness.AddUserToGroup;
import com.pulumi.harness.AddUserToGroupArgs;
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) {
        final var exampleUser = HarnessFunctions.getUser(GetUserArgs.builder()
            .email("testuser@example.com")
            .build());

        var admin = new UserGroup("admin", UserGroupArgs.builder()
            .name("admin")
            .build());

        var exampleAddUserToGroups = new AddUserToGroup("exampleAddUserToGroups", AddUserToGroupArgs.builder()
            .groupId(admin.id())
            .userId(test.id())
            .build());

    }
}
Copy
resources:
  admin:
    type: harness:UserGroup
    properties:
      name: admin
  exampleAddUserToGroups:
    type: harness:AddUserToGroup
    name: example_add_user_to_groups
    properties:
      groupId: ${admin.id}
      userId: ${test.id}
variables:
  exampleUser:
    fn::invoke:
      function: harness:getUser
      arguments:
        email: testuser@example.com
Copy

Create AddUserToGroup Resource

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

Constructor syntax

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

@overload
def AddUserToGroup(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   group_id: Optional[str] = None,
                   user_id: Optional[str] = None)
func NewAddUserToGroup(ctx *Context, name string, args AddUserToGroupArgs, opts ...ResourceOption) (*AddUserToGroup, error)
public AddUserToGroup(string name, AddUserToGroupArgs args, CustomResourceOptions? opts = null)
public AddUserToGroup(String name, AddUserToGroupArgs args)
public AddUserToGroup(String name, AddUserToGroupArgs args, CustomResourceOptions options)
type: harness:AddUserToGroup
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 This property is required. AddUserToGroupArgs
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 This property is required. AddUserToGroupArgs
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 This property is required. AddUserToGroupArgs
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 This property is required. AddUserToGroupArgs
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. AddUserToGroupArgs
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 addUserToGroupResource = new Harness.AddUserToGroup("addUserToGroupResource", new()
{
    GroupId = "string",
    UserId = "string",
});
Copy
example, err := harness.NewAddUserToGroup(ctx, "addUserToGroupResource", &harness.AddUserToGroupArgs{
	GroupId: pulumi.String("string"),
	UserId:  pulumi.String("string"),
})
Copy
var addUserToGroupResource = new AddUserToGroup("addUserToGroupResource", AddUserToGroupArgs.builder()
    .groupId("string")
    .userId("string")
    .build());
Copy
add_user_to_group_resource = harness.AddUserToGroup("addUserToGroupResource",
    group_id="string",
    user_id="string")
Copy
const addUserToGroupResource = new harness.AddUserToGroup("addUserToGroupResource", {
    groupId: "string",
    userId: "string",
});
Copy
type: harness:AddUserToGroup
properties:
    groupId: string
    userId: string
Copy

AddUserToGroup 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 AddUserToGroup resource accepts the following input properties:

GroupId
This property is required.
Changes to this property will trigger replacement.
string
The name of the user.
UserId
This property is required.
Changes to this property will trigger replacement.
string
Unique identifier of the user.
GroupId
This property is required.
Changes to this property will trigger replacement.
string
The name of the user.
UserId
This property is required.
Changes to this property will trigger replacement.
string
Unique identifier of the user.
groupId
This property is required.
Changes to this property will trigger replacement.
String
The name of the user.
userId
This property is required.
Changes to this property will trigger replacement.
String
Unique identifier of the user.
groupId
This property is required.
Changes to this property will trigger replacement.
string
The name of the user.
userId
This property is required.
Changes to this property will trigger replacement.
string
Unique identifier of the user.
group_id
This property is required.
Changes to this property will trigger replacement.
str
The name of the user.
user_id
This property is required.
Changes to this property will trigger replacement.
str
Unique identifier of the user.
groupId
This property is required.
Changes to this property will trigger replacement.
String
The name of the user.
userId
This property is required.
Changes to this property will trigger replacement.
String
Unique identifier of the user.

Outputs

All input properties are implicitly available as output properties. Additionally, the AddUserToGroup 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 AddUserToGroup Resource

Get an existing AddUserToGroup 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?: AddUserToGroupState, opts?: CustomResourceOptions): AddUserToGroup
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        group_id: Optional[str] = None,
        user_id: Optional[str] = None) -> AddUserToGroup
func GetAddUserToGroup(ctx *Context, name string, id IDInput, state *AddUserToGroupState, opts ...ResourceOption) (*AddUserToGroup, error)
public static AddUserToGroup Get(string name, Input<string> id, AddUserToGroupState? state, CustomResourceOptions? opts = null)
public static AddUserToGroup get(String name, Output<String> id, AddUserToGroupState state, CustomResourceOptions options)
resources:  _:    type: harness:AddUserToGroup    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:
GroupId Changes to this property will trigger replacement. string
The name of the user.
UserId Changes to this property will trigger replacement. string
Unique identifier of the user.
GroupId Changes to this property will trigger replacement. string
The name of the user.
UserId Changes to this property will trigger replacement. string
Unique identifier of the user.
groupId Changes to this property will trigger replacement. String
The name of the user.
userId Changes to this property will trigger replacement. String
Unique identifier of the user.
groupId Changes to this property will trigger replacement. string
The name of the user.
userId Changes to this property will trigger replacement. string
Unique identifier of the user.
group_id Changes to this property will trigger replacement. str
The name of the user.
user_id Changes to this property will trigger replacement. str
Unique identifier of the user.
groupId Changes to this property will trigger replacement. String
The name of the user.
userId Changes to this property will trigger replacement. String
Unique identifier of the user.

Import

Import using the Harness user and user group id

$ pulumi import harness:index/addUserToGroup:AddUserToGroup example_admin <user_id>/<group_id>
Copy

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

Package Details

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