1. Packages
  2. Grafana Cloud
  3. API Docs
  4. DataSourcePermission
Grafana v0.9.0 published on Thursday, Dec 12, 2024 by pulumiverse

grafana.DataSourcePermission

Explore with Pulumi AI

grafana logo
Grafana v0.9.0 published on Thursday, Dec 12, 2024 by pulumiverse
    Deprecated: grafana.index/datasourcepermission.DataSourcePermission has been deprecated in favor of grafana.enterprise/datasourcepermission.DataSourcePermission

    Manages the entire set of permissions for a datasource. Permissions that aren’t specified when applying this resource will be removed.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumiverse/grafana";
    
    const team = new grafana.oss.Team("team", {name: "Team Name"});
    const foo = new grafana.oss.DataSource("foo", {
        type: "cloudwatch",
        name: "cw-example",
        jsonDataEncoded: JSON.stringify({
            defaultRegion: "us-east-1",
            authType: "keys",
        }),
        secureJsonDataEncoded: JSON.stringify({
            accessKey: "123",
            secretKey: "456",
        }),
    });
    const user = new grafana.oss.User("user", {
        name: "test-ds-permissions",
        email: "test-ds-permissions@example.com",
        login: "test-ds-permissions",
        password: "hunter2",
    });
    const sa = new grafana.oss.ServiceAccount("sa", {
        name: "test-ds-permissions",
        role: "Viewer",
    });
    const fooPermissions = new grafana.enterprise.DataSourcePermission("fooPermissions", {
        datasourceUid: foo.uid,
        permissions: [
            {
                teamId: team.id,
                permission: "Edit",
            },
            {
                userId: user.id,
                permission: "Edit",
            },
            {
                builtInRole: "Viewer",
                permission: "Query",
            },
            {
                userId: sa.id,
                permission: "Query",
            },
        ],
    });
    
    import pulumi
    import json
    import pulumiverse_grafana as grafana
    
    team = grafana.oss.Team("team", name="Team Name")
    foo = grafana.oss.DataSource("foo",
        type="cloudwatch",
        name="cw-example",
        json_data_encoded=json.dumps({
            "defaultRegion": "us-east-1",
            "authType": "keys",
        }),
        secure_json_data_encoded=json.dumps({
            "accessKey": "123",
            "secretKey": "456",
        }))
    user = grafana.oss.User("user",
        name="test-ds-permissions",
        email="test-ds-permissions@example.com",
        login="test-ds-permissions",
        password="hunter2")
    sa = grafana.oss.ServiceAccount("sa",
        name="test-ds-permissions",
        role="Viewer")
    foo_permissions = grafana.enterprise.DataSourcePermission("fooPermissions",
        datasource_uid=foo.uid,
        permissions=[
            {
                "team_id": team.id,
                "permission": "Edit",
            },
            {
                "user_id": user.id,
                "permission": "Edit",
            },
            {
                "built_in_role": "Viewer",
                "permission": "Query",
            },
            {
                "user_id": sa.id,
                "permission": "Query",
            },
        ])
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/enterprise"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana/oss"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		team, err := oss.NewTeam(ctx, "team", &oss.TeamArgs{
    			Name: pulumi.String("Team Name"),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"defaultRegion": "us-east-1",
    			"authType":      "keys",
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		tmpJSON1, err := json.Marshal(map[string]interface{}{
    			"accessKey": "123",
    			"secretKey": "456",
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		foo, err := oss.NewDataSource(ctx, "foo", &oss.DataSourceArgs{
    			Type:                  pulumi.String("cloudwatch"),
    			Name:                  pulumi.String("cw-example"),
    			JsonDataEncoded:       pulumi.String(json0),
    			SecureJsonDataEncoded: pulumi.String(json1),
    		})
    		if err != nil {
    			return err
    		}
    		user, err := oss.NewUser(ctx, "user", &oss.UserArgs{
    			Name:     pulumi.String("test-ds-permissions"),
    			Email:    pulumi.String("test-ds-permissions@example.com"),
    			Login:    pulumi.String("test-ds-permissions"),
    			Password: pulumi.String("hunter2"),
    		})
    		if err != nil {
    			return err
    		}
    		sa, err := oss.NewServiceAccount(ctx, "sa", &oss.ServiceAccountArgs{
    			Name: pulumi.String("test-ds-permissions"),
    			Role: pulumi.String("Viewer"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = enterprise.NewDataSourcePermission(ctx, "fooPermissions", &enterprise.DataSourcePermissionArgs{
    			DatasourceUid: foo.Uid,
    			Permissions: enterprise.DataSourcePermissionPermissionArray{
    				&enterprise.DataSourcePermissionPermissionArgs{
    					TeamId:     team.ID(),
    					Permission: pulumi.String("Edit"),
    				},
    				&enterprise.DataSourcePermissionPermissionArgs{
    					UserId:     user.ID(),
    					Permission: pulumi.String("Edit"),
    				},
    				&enterprise.DataSourcePermissionPermissionArgs{
    					BuiltInRole: pulumi.String("Viewer"),
    					Permission:  pulumi.String("Query"),
    				},
    				&enterprise.DataSourcePermissionPermissionArgs{
    					UserId:     sa.ID(),
    					Permission: pulumi.String("Query"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var team = new Grafana.Oss.Team("team", new()
        {
            Name = "Team Name",
        });
    
        var foo = new Grafana.Oss.DataSource("foo", new()
        {
            Type = "cloudwatch",
            Name = "cw-example",
            JsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["defaultRegion"] = "us-east-1",
                ["authType"] = "keys",
            }),
            SecureJsonDataEncoded = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["accessKey"] = "123",
                ["secretKey"] = "456",
            }),
        });
    
        var user = new Grafana.Oss.User("user", new()
        {
            Name = "test-ds-permissions",
            Email = "test-ds-permissions@example.com",
            Login = "test-ds-permissions",
            Password = "hunter2",
        });
    
        var sa = new Grafana.Oss.ServiceAccount("sa", new()
        {
            Name = "test-ds-permissions",
            Role = "Viewer",
        });
    
        var fooPermissions = new Grafana.Enterprise.DataSourcePermission("fooPermissions", new()
        {
            DatasourceUid = foo.Uid,
            Permissions = new[]
            {
                new Grafana.Enterprise.Inputs.DataSourcePermissionPermissionArgs
                {
                    TeamId = team.Id,
                    Permission = "Edit",
                },
                new Grafana.Enterprise.Inputs.DataSourcePermissionPermissionArgs
                {
                    UserId = user.Id,
                    Permission = "Edit",
                },
                new Grafana.Enterprise.Inputs.DataSourcePermissionPermissionArgs
                {
                    BuiltInRole = "Viewer",
                    Permission = "Query",
                },
                new Grafana.Enterprise.Inputs.DataSourcePermissionPermissionArgs
                {
                    UserId = sa.Id,
                    Permission = "Query",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.oss.Team;
    import com.pulumi.grafana.oss.TeamArgs;
    import com.pulumi.grafana.oss.DataSource;
    import com.pulumi.grafana.oss.DataSourceArgs;
    import com.pulumi.grafana.oss.User;
    import com.pulumi.grafana.oss.UserArgs;
    import com.pulumi.grafana.oss.ServiceAccount;
    import com.pulumi.grafana.oss.ServiceAccountArgs;
    import com.pulumi.grafana.enterprise.DataSourcePermission;
    import com.pulumi.grafana.enterprise.DataSourcePermissionArgs;
    import com.pulumi.grafana.enterprise.inputs.DataSourcePermissionPermissionArgs;
    import static com.pulumi.codegen.internal.Serialization.*;
    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 team = new Team("team", TeamArgs.builder()
                .name("Team Name")
                .build());
    
            var foo = new DataSource("foo", DataSourceArgs.builder()
                .type("cloudwatch")
                .name("cw-example")
                .jsonDataEncoded(serializeJson(
                    jsonObject(
                        jsonProperty("defaultRegion", "us-east-1"),
                        jsonProperty("authType", "keys")
                    )))
                .secureJsonDataEncoded(serializeJson(
                    jsonObject(
                        jsonProperty("accessKey", "123"),
                        jsonProperty("secretKey", "456")
                    )))
                .build());
    
            var user = new User("user", UserArgs.builder()
                .name("test-ds-permissions")
                .email("test-ds-permissions@example.com")
                .login("test-ds-permissions")
                .password("hunter2")
                .build());
    
            var sa = new ServiceAccount("sa", ServiceAccountArgs.builder()
                .name("test-ds-permissions")
                .role("Viewer")
                .build());
    
            var fooPermissions = new DataSourcePermission("fooPermissions", DataSourcePermissionArgs.builder()
                .datasourceUid(foo.uid())
                .permissions(            
                    DataSourcePermissionPermissionArgs.builder()
                        .teamId(team.id())
                        .permission("Edit")
                        .build(),
                    DataSourcePermissionPermissionArgs.builder()
                        .userId(user.id())
                        .permission("Edit")
                        .build(),
                    DataSourcePermissionPermissionArgs.builder()
                        .builtInRole("Viewer")
                        .permission("Query")
                        .build(),
                    DataSourcePermissionPermissionArgs.builder()
                        .userId(sa.id())
                        .permission("Query")
                        .build())
                .build());
    
        }
    }
    
    resources:
      team:
        type: grafana:oss:Team
        properties:
          name: Team Name
      foo:
        type: grafana:oss:DataSource
        properties:
          type: cloudwatch
          name: cw-example
          jsonDataEncoded:
            fn::toJSON:
              defaultRegion: us-east-1
              authType: keys
          secureJsonDataEncoded:
            fn::toJSON:
              accessKey: '123'
              secretKey: '456'
      user:
        type: grafana:oss:User
        properties:
          name: test-ds-permissions
          email: test-ds-permissions@example.com
          login: test-ds-permissions
          password: hunter2
      sa:
        type: grafana:oss:ServiceAccount
        properties:
          name: test-ds-permissions
          role: Viewer
      fooPermissions:
        type: grafana:enterprise:DataSourcePermission
        properties:
          datasourceUid: ${foo.uid}
          permissions:
            - teamId: ${team.id}
              permission: Edit
            - userId: ${user.id}
              permission: Edit
            - builtInRole: Viewer
              permission: Query
            - userId: ${sa.id}
              permission: Query
    

    Create DataSourcePermission Resource

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

    Constructor syntax

    new DataSourcePermission(name: string, args: DataSourcePermissionArgs, opts?: CustomResourceOptions);
    @overload
    def DataSourcePermission(resource_name: str,
                             args: DataSourcePermissionArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def DataSourcePermission(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             datasource_uid: Optional[str] = None,
                             org_id: Optional[str] = None,
                             permissions: Optional[Sequence[DataSourcePermissionPermissionArgs]] = None)
    func NewDataSourcePermission(ctx *Context, name string, args DataSourcePermissionArgs, opts ...ResourceOption) (*DataSourcePermission, error)
    public DataSourcePermission(string name, DataSourcePermissionArgs args, CustomResourceOptions? opts = null)
    public DataSourcePermission(String name, DataSourcePermissionArgs args)
    public DataSourcePermission(String name, DataSourcePermissionArgs args, CustomResourceOptions options)
    
    type: grafana:DataSourcePermission
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

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

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

    DatasourceUid string
    UID of the datasource to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions List<Pulumiverse.Grafana.Inputs.DataSourcePermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    DatasourceUid string
    UID of the datasource to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions []DataSourcePermissionPermissionArgs
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasourceUid String
    UID of the datasource to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<DataSourcePermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasourceUid string
    UID of the datasource to apply permissions to.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions DataSourcePermissionPermission[]
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasource_uid str
    UID of the datasource to apply permissions to.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions Sequence[DataSourcePermissionPermissionArgs]
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasourceUid String
    UID of the datasource to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<Property Map>
    The permission items to add/update. Items that are omitted from the list will be removed.

    Outputs

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

    Get an existing DataSourcePermission 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?: DataSourcePermissionState, opts?: CustomResourceOptions): DataSourcePermission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            datasource_uid: Optional[str] = None,
            org_id: Optional[str] = None,
            permissions: Optional[Sequence[DataSourcePermissionPermissionArgs]] = None) -> DataSourcePermission
    func GetDataSourcePermission(ctx *Context, name string, id IDInput, state *DataSourcePermissionState, opts ...ResourceOption) (*DataSourcePermission, error)
    public static DataSourcePermission Get(string name, Input<string> id, DataSourcePermissionState? state, CustomResourceOptions? opts = null)
    public static DataSourcePermission get(String name, Output<String> id, DataSourcePermissionState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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:
    DatasourceUid string
    UID of the datasource to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions List<Pulumiverse.Grafana.Inputs.DataSourcePermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    DatasourceUid string
    UID of the datasource to apply permissions to.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions []DataSourcePermissionPermissionArgs
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasourceUid String
    UID of the datasource to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<DataSourcePermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasourceUid string
    UID of the datasource to apply permissions to.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions DataSourcePermissionPermission[]
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasource_uid str
    UID of the datasource to apply permissions to.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions Sequence[DataSourcePermissionPermissionArgs]
    The permission items to add/update. Items that are omitted from the list will be removed.
    datasourceUid String
    UID of the datasource to apply permissions to.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<Property Map>
    The permission items to add/update. Items that are omitted from the list will be removed.

    Supporting Types

    DataSourcePermissionPermission, DataSourcePermissionPermissionArgs

    Permission string
    Permission to associate with item. Options: Query, Edit or Admin (Admin can only be used with Grafana v10.3.0+).
    BuiltInRole string
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    TeamId string
    ID of the team to manage permissions for. Defaults to 0.
    UserId string
    ID of the user or service account to manage permissions for. Defaults to 0.
    Permission string
    Permission to associate with item. Options: Query, Edit or Admin (Admin can only be used with Grafana v10.3.0+).
    BuiltInRole string
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    TeamId string
    ID of the team to manage permissions for. Defaults to 0.
    UserId string
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission String
    Permission to associate with item. Options: Query, Edit or Admin (Admin can only be used with Grafana v10.3.0+).
    builtInRole String
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    teamId String
    ID of the team to manage permissions for. Defaults to 0.
    userId String
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission string
    Permission to associate with item. Options: Query, Edit or Admin (Admin can only be used with Grafana v10.3.0+).
    builtInRole string
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    teamId string
    ID of the team to manage permissions for. Defaults to 0.
    userId string
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission str
    Permission to associate with item. Options: Query, Edit or Admin (Admin can only be used with Grafana v10.3.0+).
    built_in_role str
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    team_id str
    ID of the team to manage permissions for. Defaults to 0.
    user_id str
    ID of the user or service account to manage permissions for. Defaults to 0.
    permission String
    Permission to associate with item. Options: Query, Edit or Admin (Admin can only be used with Grafana v10.3.0+).
    builtInRole String
    Name of the basic role to manage permissions for. Options: Viewer, Editor or Admin.
    teamId String
    ID of the team to manage permissions for. Defaults to 0.
    userId String
    ID of the user or service account to manage permissions for. Defaults to 0.

    Import

    $ pulumi import grafana:index/dataSourcePermission:DataSourcePermission name "{{ datasourceID }}"
    
    $ pulumi import grafana:index/dataSourcePermission:DataSourcePermission name "{{ orgID }}:{{ datasourceID }}"
    

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

    Package Details

    Repository
    grafana pulumiverse/pulumi-grafana
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the grafana Terraform Provider.
    grafana logo
    Grafana v0.9.0 published on Thursday, Dec 12, 2024 by pulumiverse