1. Packages
  2. Datadog Provider
  3. API Docs
  4. UserRole
Datadog v4.49.0 published on Thursday, Apr 17, 2025 by Pulumi

datadog.UserRole

Explore with Pulumi AI

Provides a Datadog UserRole resource. This can be used to create and manage Datadog User Roles. Conflicts may occur if used together with the datadog.User resource’s roles attribute or the datadog.ServiceAccount resource’s roles attribute. This resource is in beta and is subject to change.

Example Usage

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

const monitorWriterRole = new datadog.Role("monitor_writer_role", {
    name: "Monitor Writer Role",
    permissions: [{
        id: bar.permissions.monitorsWrite,
    }],
});
const newUser = new datadog.User("new_user", {email: "new@example.com"});
// Create new user_role resource
const newUserWithMonitorWriterRole = new datadog.UserRole("new_user_with_monitor_writer_role", {
    roleId: monitorWriterRole.id,
    userId: newUser.id,
});
Copy
import pulumi
import pulumi_datadog as datadog

monitor_writer_role = datadog.Role("monitor_writer_role",
    name="Monitor Writer Role",
    permissions=[{
        "id": bar["permissions"]["monitorsWrite"],
    }])
new_user = datadog.User("new_user", email="new@example.com")
# Create new user_role resource
new_user_with_monitor_writer_role = datadog.UserRole("new_user_with_monitor_writer_role",
    role_id=monitor_writer_role.id,
    user_id=new_user.id)
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		monitorWriterRole, err := datadog.NewRole(ctx, "monitor_writer_role", &datadog.RoleArgs{
			Name: pulumi.String("Monitor Writer Role"),
			Permissions: datadog.RolePermissionArray{
				&datadog.RolePermissionArgs{
					Id: pulumi.Any(bar.Permissions.MonitorsWrite),
				},
			},
		})
		if err != nil {
			return err
		}
		newUser, err := datadog.NewUser(ctx, "new_user", &datadog.UserArgs{
			Email: pulumi.String("new@example.com"),
		})
		if err != nil {
			return err
		}
		// Create new user_role resource
		_, err = datadog.NewUserRole(ctx, "new_user_with_monitor_writer_role", &datadog.UserRoleArgs{
			RoleId: monitorWriterRole.ID(),
			UserId: newUser.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Datadog = Pulumi.Datadog;

return await Deployment.RunAsync(() => 
{
    var monitorWriterRole = new Datadog.Role("monitor_writer_role", new()
    {
        Name = "Monitor Writer Role",
        Permissions = new[]
        {
            new Datadog.Inputs.RolePermissionArgs
            {
                Id = bar.Permissions.MonitorsWrite,
            },
        },
    });

    var newUser = new Datadog.User("new_user", new()
    {
        Email = "new@example.com",
    });

    // Create new user_role resource
    var newUserWithMonitorWriterRole = new Datadog.UserRole("new_user_with_monitor_writer_role", new()
    {
        RoleId = monitorWriterRole.Id,
        UserId = newUser.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.datadog.Role;
import com.pulumi.datadog.RoleArgs;
import com.pulumi.datadog.inputs.RolePermissionArgs;
import com.pulumi.datadog.User;
import com.pulumi.datadog.UserArgs;
import com.pulumi.datadog.UserRole;
import com.pulumi.datadog.UserRoleArgs;
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 monitorWriterRole = new Role("monitorWriterRole", RoleArgs.builder()
            .name("Monitor Writer Role")
            .permissions(RolePermissionArgs.builder()
                .id(bar.permissions().monitorsWrite())
                .build())
            .build());

        var newUser = new User("newUser", UserArgs.builder()
            .email("new@example.com")
            .build());

        // Create new user_role resource
        var newUserWithMonitorWriterRole = new UserRole("newUserWithMonitorWriterRole", UserRoleArgs.builder()
            .roleId(monitorWriterRole.id())
            .userId(newUser.id())
            .build());

    }
}
Copy
resources:
  monitorWriterRole:
    type: datadog:Role
    name: monitor_writer_role
    properties:
      name: Monitor Writer Role
      permissions:
        - id: ${bar.permissions.monitorsWrite}
  newUser:
    type: datadog:User
    name: new_user
    properties:
      email: new@example.com
  # Create new user_role resource
  newUserWithMonitorWriterRole:
    type: datadog:UserRole
    name: new_user_with_monitor_writer_role
    properties:
      roleId: ${monitorWriterRole.id}
      userId: ${newUser.id}
Copy

Create UserRole Resource

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

Constructor syntax

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

@overload
def UserRole(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             role_id: Optional[str] = None,
             user_id: Optional[str] = None)
func NewUserRole(ctx *Context, name string, args UserRoleArgs, opts ...ResourceOption) (*UserRole, error)
public UserRole(string name, UserRoleArgs args, CustomResourceOptions? opts = null)
public UserRole(String name, UserRoleArgs args)
public UserRole(String name, UserRoleArgs args, CustomResourceOptions options)
type: datadog:UserRole
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. UserRoleArgs
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. UserRoleArgs
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. UserRoleArgs
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. UserRoleArgs
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. UserRoleArgs
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 userRoleResource = new Datadog.UserRole("userRoleResource", new()
{
    RoleId = "string",
    UserId = "string",
});
Copy
example, err := datadog.NewUserRole(ctx, "userRoleResource", &datadog.UserRoleArgs{
	RoleId: pulumi.String("string"),
	UserId: pulumi.String("string"),
})
Copy
var userRoleResource = new UserRole("userRoleResource", UserRoleArgs.builder()
    .roleId("string")
    .userId("string")
    .build());
Copy
user_role_resource = datadog.UserRole("userRoleResource",
    role_id="string",
    user_id="string")
Copy
const userRoleResource = new datadog.UserRole("userRoleResource", {
    roleId: "string",
    userId: "string",
});
Copy
type: datadog:UserRole
properties:
    roleId: string
    userId: string
Copy

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

RoleId This property is required. string
ID of the role that the user is assigned to.
UserId This property is required. string
The ID of the user.
RoleId This property is required. string
ID of the role that the user is assigned to.
UserId This property is required. string
The ID of the user.
roleId This property is required. String
ID of the role that the user is assigned to.
userId This property is required. String
The ID of the user.
roleId This property is required. string
ID of the role that the user is assigned to.
userId This property is required. string
The ID of the user.
role_id This property is required. str
ID of the role that the user is assigned to.
user_id This property is required. str
The ID of the user.
roleId This property is required. String
ID of the role that the user is assigned to.
userId This property is required. String
The ID of the user.

Outputs

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

Get an existing UserRole 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?: UserRoleState, opts?: CustomResourceOptions): UserRole
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        role_id: Optional[str] = None,
        user_id: Optional[str] = None) -> UserRole
func GetUserRole(ctx *Context, name string, id IDInput, state *UserRoleState, opts ...ResourceOption) (*UserRole, error)
public static UserRole Get(string name, Input<string> id, UserRoleState? state, CustomResourceOptions? opts = null)
public static UserRole get(String name, Output<String> id, UserRoleState state, CustomResourceOptions options)
resources:  _:    type: datadog:UserRole    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:
RoleId string
ID of the role that the user is assigned to.
UserId string
The ID of the user.
RoleId string
ID of the role that the user is assigned to.
UserId string
The ID of the user.
roleId String
ID of the role that the user is assigned to.
userId String
The ID of the user.
roleId string
ID of the role that the user is assigned to.
userId string
The ID of the user.
role_id str
ID of the role that the user is assigned to.
user_id str
The ID of the user.
roleId String
ID of the role that the user is assigned to.
userId String
The ID of the user.

Import

This resource is imported using user_id and role_id seperated by :.

$ pulumi import datadog:index/userRole:UserRole user_with_admin_role "${role_id}:${user_id}"
Copy

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

Package Details

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