1. Packages
  2. Grafana Cloud
  3. API Docs
  4. getUser
Grafana v0.16.1 published on Saturday, Mar 15, 2025 by pulumiverse

grafana.getUser

Explore with Pulumi AI

Grafana v0.16.1 published on Saturday, Mar 15, 2025 by pulumiverse
Deprecated: grafana.index/getuser.getUser has been deprecated in favor of grafana.oss/getuser.getUser

This data source uses Grafana’s admin APIs for reading users which does not currently work with API Tokens. You must use basic auth. This data source is also not compatible with Grafana Cloud, as it does not allow basic auth.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as grafana from "@pulumi/grafana";
import * as grafana from "@pulumiverse/grafana";

const test = new grafana.oss.User("test", {
    email: "test.datasource@example.com",
    name: "Testing Datasource",
    login: "test-datasource",
    password: "my-password",
    isAdmin: true,
});
const fromId = grafana.oss.getUserOutput({
    userId: test.userId,
});
const fromEmail = grafana.oss.getUserOutput({
    email: test.email,
});
const fromLogin = test.login.apply(login => grafana.oss.getUserOutput({
    login: login,
}));
Copy
import pulumi
import pulumi_grafana as grafana
import pulumiverse_grafana as grafana

test = grafana.oss.User("test",
    email="test.datasource@example.com",
    name="Testing Datasource",
    login="test-datasource",
    password="my-password",
    is_admin=True)
from_id = grafana.oss.get_user_output(user_id=test.user_id)
from_email = grafana.oss.get_user_output(email=test.email)
from_login = test.login.apply(lambda login: grafana.oss.get_user_output(login=login))
Copy
package main

import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/oss"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		test, err := oss.NewUser(ctx, "test", &oss.UserArgs{
			Email:    pulumi.String("test.datasource@example.com"),
			Name:     pulumi.String("Testing Datasource"),
			Login:    pulumi.String("test-datasource"),
			Password: pulumi.String("my-password"),
			IsAdmin:  pulumi.Bool(true),
		})
		if err != nil {
			return err
		}
		_ = oss.LookupUserOutput(ctx, oss.GetUserOutputArgs{
			UserId: test.UserId,
		}, nil)
		_ = oss.LookupUserOutput(ctx, oss.GetUserOutputArgs{
			Email: test.Email,
		}, nil)
		_ = test.Login.ApplyT(func(login *string) (oss.GetUserResult, error) {
			return oss.GetUserResult(interface{}(oss.LookupUserOutput(ctx, oss.GetUserOutputArgs{
				Login: login,
			}, nil))), nil
		}).(oss.GetUserResultOutput)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Grafana = Pulumi.Grafana;
using Grafana = Pulumiverse.Grafana;

return await Deployment.RunAsync(() => 
{
    var test = new Grafana.Oss.User("test", new()
    {
        Email = "test.datasource@example.com",
        Name = "Testing Datasource",
        Login = "test-datasource",
        Password = "my-password",
        IsAdmin = true,
    });

    var fromId = Grafana.Oss.GetUser.Invoke(new()
    {
        UserId = test.UserId,
    });

    var fromEmail = Grafana.Oss.GetUser.Invoke(new()
    {
        Email = test.Email,
    });

    var fromLogin = Grafana.Oss.GetUser.Invoke(new()
    {
        Login = test.Login,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.grafana.oss.User;
import com.pulumi.grafana.oss.UserArgs;
import com.pulumi.grafana.oss.OssFunctions;
import com.pulumi.grafana.oss.inputs.GetUserArgs;
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 test = new User("test", UserArgs.builder()
            .email("test.datasource@example.com")
            .name("Testing Datasource")
            .login("test-datasource")
            .password("my-password")
            .isAdmin(true)
            .build());

        final var fromId = OssFunctions.getUser(GetUserArgs.builder()
            .userId(test.userId())
            .build());

        final var fromEmail = OssFunctions.getUser(GetUserArgs.builder()
            .email(test.email())
            .build());

        final var fromLogin = OssFunctions.getUser(GetUserArgs.builder()
            .login(test.login())
            .build());

    }
}
Copy
resources:
  test:
    type: grafana:oss:User
    properties:
      email: test.datasource@example.com
      name: Testing Datasource
      login: test-datasource
      password: my-password
      isAdmin: true
variables:
  fromId:
    fn::invoke:
      function: grafana:oss:getUser
      arguments:
        userId: ${test.userId}
  fromEmail:
    fn::invoke:
      function: grafana:oss:getUser
      arguments:
        email: ${test.email}
  fromLogin:
    fn::invoke:
      function: grafana:oss:getUser
      arguments:
        login: ${test.login}
Copy

Using getUser

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getUser(args: GetUserArgs, opts?: InvokeOptions): Promise<GetUserResult>
function getUserOutput(args: GetUserOutputArgs, opts?: InvokeOptions): Output<GetUserResult>
Copy
def get_user(email: Optional[str] = None,
             login: Optional[str] = None,
             user_id: Optional[int] = None,
             opts: Optional[InvokeOptions] = None) -> GetUserResult
def get_user_output(email: Optional[pulumi.Input[str]] = None,
             login: Optional[pulumi.Input[str]] = None,
             user_id: Optional[pulumi.Input[int]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetUserResult]
Copy
func LookupUser(ctx *Context, args *LookupUserArgs, opts ...InvokeOption) (*LookupUserResult, error)
func LookupUserOutput(ctx *Context, args *LookupUserOutputArgs, opts ...InvokeOption) LookupUserResultOutput
Copy

> Note: This function is named LookupUser in the Go SDK.

public static class GetUser 
{
    public static Task<GetUserResult> InvokeAsync(GetUserArgs args, InvokeOptions? opts = null)
    public static Output<GetUserResult> Invoke(GetUserInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetUserResult> getUser(GetUserArgs args, InvokeOptions options)
public static Output<GetUserResult> getUser(GetUserArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: grafana:index/getUser:getUser
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Email string
The email address of the Grafana user. Defaults to ``.
Login string
The username for the Grafana user. Defaults to ``.
UserId int
The numerical ID of the Grafana user. Defaults to -1.
Email string
The email address of the Grafana user. Defaults to ``.
Login string
The username for the Grafana user. Defaults to ``.
UserId int
The numerical ID of the Grafana user. Defaults to -1.
email String
The email address of the Grafana user. Defaults to ``.
login String
The username for the Grafana user. Defaults to ``.
userId Integer
The numerical ID of the Grafana user. Defaults to -1.
email string
The email address of the Grafana user. Defaults to ``.
login string
The username for the Grafana user. Defaults to ``.
userId number
The numerical ID of the Grafana user. Defaults to -1.
email str
The email address of the Grafana user. Defaults to ``.
login str
The username for the Grafana user. Defaults to ``.
user_id int
The numerical ID of the Grafana user. Defaults to -1.
email String
The email address of the Grafana user. Defaults to ``.
login String
The username for the Grafana user. Defaults to ``.
userId Number
The numerical ID of the Grafana user. Defaults to -1.

getUser Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
IsAdmin bool
Whether the user is an admin.
Name string
The display name for the Grafana user.
Email string
The email address of the Grafana user. Defaults to ``.
Login string
The username for the Grafana user. Defaults to ``.
UserId int
The numerical ID of the Grafana user. Defaults to -1.
Id string
The provider-assigned unique ID for this managed resource.
IsAdmin bool
Whether the user is an admin.
Name string
The display name for the Grafana user.
Email string
The email address of the Grafana user. Defaults to ``.
Login string
The username for the Grafana user. Defaults to ``.
UserId int
The numerical ID of the Grafana user. Defaults to -1.
id String
The provider-assigned unique ID for this managed resource.
isAdmin Boolean
Whether the user is an admin.
name String
The display name for the Grafana user.
email String
The email address of the Grafana user. Defaults to ``.
login String
The username for the Grafana user. Defaults to ``.
userId Integer
The numerical ID of the Grafana user. Defaults to -1.
id string
The provider-assigned unique ID for this managed resource.
isAdmin boolean
Whether the user is an admin.
name string
The display name for the Grafana user.
email string
The email address of the Grafana user. Defaults to ``.
login string
The username for the Grafana user. Defaults to ``.
userId number
The numerical ID of the Grafana user. Defaults to -1.
id str
The provider-assigned unique ID for this managed resource.
is_admin bool
Whether the user is an admin.
name str
The display name for the Grafana user.
email str
The email address of the Grafana user. Defaults to ``.
login str
The username for the Grafana user. Defaults to ``.
user_id int
The numerical ID of the Grafana user. Defaults to -1.
id String
The provider-assigned unique ID for this managed resource.
isAdmin Boolean
Whether the user is an admin.
name String
The display name for the Grafana user.
email String
The email address of the Grafana user. Defaults to ``.
login String
The username for the Grafana user. Defaults to ``.
userId Number
The numerical ID of the Grafana user. Defaults to -1.

Package Details

Repository
grafana pulumiverse/pulumi-grafana
License
Apache-2.0
Notes
This Pulumi package is based on the grafana Terraform Provider.
Grafana v0.16.1 published on Saturday, Mar 15, 2025 by pulumiverse