1. Packages
  2. Grafana Cloud
  3. API Docs
  4. ServiceAccountPermission
Grafana v0.5.1 published on Wednesday, Jun 12, 2024 by pulumiverse

grafana.ServiceAccountPermission

Explore with Pulumi AI

grafana logo
Grafana v0.5.1 published on Wednesday, Jun 12, 2024 by pulumiverse

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

    Note: This resource is available from Grafana 9.2.4 onwards.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumiverse/grafana";
    
    const test = new grafana.ServiceAccount("test", {
        role: "Editor",
        isDisabled: false,
    });
    const testTeam = new grafana.Team("testTeam", {});
    const testUser = new grafana.User("testUser", {
        email: "tf_user@test.com",
        login: "tf_user@test.com",
        password: "password",
    });
    const testPermissions = new grafana.ServiceAccountPermission("testPermissions", {
        serviceAccountId: test.id,
        permissions: [
            {
                userId: testUser.id,
                permission: "Edit",
            },
            {
                teamId: testTeam.id,
                permission: "Admin",
            },
        ],
    });
    
    import pulumi
    import pulumiverse_grafana as grafana
    
    test = grafana.ServiceAccount("test",
        role="Editor",
        is_disabled=False)
    test_team = grafana.Team("testTeam")
    test_user = grafana.User("testUser",
        email="tf_user@test.com",
        login="tf_user@test.com",
        password="password")
    test_permissions = grafana.ServiceAccountPermission("testPermissions",
        service_account_id=test.id,
        permissions=[
            grafana.ServiceAccountPermissionPermissionArgs(
                user_id=test_user.id,
                permission="Edit",
            ),
            grafana.ServiceAccountPermissionPermissionArgs(
                team_id=test_team.id,
                permission="Admin",
            ),
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-grafana/sdk/go/grafana"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		test, err := grafana.NewServiceAccount(ctx, "test", &grafana.ServiceAccountArgs{
    			Role:       pulumi.String("Editor"),
    			IsDisabled: pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		testTeam, err := grafana.NewTeam(ctx, "testTeam", nil)
    		if err != nil {
    			return err
    		}
    		testUser, err := grafana.NewUser(ctx, "testUser", &grafana.UserArgs{
    			Email:    pulumi.String("tf_user@test.com"),
    			Login:    pulumi.String("tf_user@test.com"),
    			Password: pulumi.String("password"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = grafana.NewServiceAccountPermission(ctx, "testPermissions", &grafana.ServiceAccountPermissionArgs{
    			ServiceAccountId: test.ID(),
    			Permissions: grafana.ServiceAccountPermissionPermissionArray{
    				&grafana.ServiceAccountPermissionPermissionArgs{
    					UserId:     testUser.ID(),
    					Permission: pulumi.String("Edit"),
    				},
    				&grafana.ServiceAccountPermissionPermissionArgs{
    					TeamId:     testTeam.ID(),
    					Permission: pulumi.String("Admin"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Grafana = Pulumiverse.Grafana;
    
    return await Deployment.RunAsync(() => 
    {
        var test = new Grafana.ServiceAccount("test", new()
        {
            Role = "Editor",
            IsDisabled = false,
        });
    
        var testTeam = new Grafana.Team("testTeam");
    
        var testUser = new Grafana.User("testUser", new()
        {
            Email = "tf_user@test.com",
            Login = "tf_user@test.com",
            Password = "password",
        });
    
        var testPermissions = new Grafana.ServiceAccountPermission("testPermissions", new()
        {
            ServiceAccountId = test.Id,
            Permissions = new[]
            {
                new Grafana.Inputs.ServiceAccountPermissionPermissionArgs
                {
                    UserId = testUser.Id,
                    Permission = "Edit",
                },
                new Grafana.Inputs.ServiceAccountPermissionPermissionArgs
                {
                    TeamId = testTeam.Id,
                    Permission = "Admin",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.ServiceAccount;
    import com.pulumi.grafana.ServiceAccountArgs;
    import com.pulumi.grafana.Team;
    import com.pulumi.grafana.User;
    import com.pulumi.grafana.UserArgs;
    import com.pulumi.grafana.ServiceAccountPermission;
    import com.pulumi.grafana.ServiceAccountPermissionArgs;
    import com.pulumi.grafana.inputs.ServiceAccountPermissionPermissionArgs;
    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 ServiceAccount("test", ServiceAccountArgs.builder()        
                .role("Editor")
                .isDisabled(false)
                .build());
    
            var testTeam = new Team("testTeam");
    
            var testUser = new User("testUser", UserArgs.builder()        
                .email("tf_user@test.com")
                .login("tf_user@test.com")
                .password("password")
                .build());
    
            var testPermissions = new ServiceAccountPermission("testPermissions", ServiceAccountPermissionArgs.builder()        
                .serviceAccountId(test.id())
                .permissions(            
                    ServiceAccountPermissionPermissionArgs.builder()
                        .userId(testUser.id())
                        .permission("Edit")
                        .build(),
                    ServiceAccountPermissionPermissionArgs.builder()
                        .teamId(testTeam.id())
                        .permission("Admin")
                        .build())
                .build());
    
        }
    }
    
    resources:
      test:
        type: grafana:ServiceAccount
        properties:
          role: Editor
          isDisabled: false
      testTeam:
        type: grafana:Team
      testUser:
        type: grafana:User
        properties:
          email: tf_user@test.com
          login: tf_user@test.com
          password: password
      testPermissions:
        type: grafana:ServiceAccountPermission
        properties:
          serviceAccountId: ${test.id}
          permissions:
            - userId: ${testUser.id}
              permission: Edit
            - teamId: ${testTeam.id}
              permission: Admin
    

    Create ServiceAccountPermission Resource

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

    Constructor syntax

    new ServiceAccountPermission(name: string, args: ServiceAccountPermissionArgs, opts?: CustomResourceOptions);
    @overload
    def ServiceAccountPermission(resource_name: str,
                                 args: ServiceAccountPermissionArgs,
                                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def ServiceAccountPermission(resource_name: str,
                                 opts: Optional[ResourceOptions] = None,
                                 service_account_id: Optional[str] = None,
                                 org_id: Optional[str] = None,
                                 permissions: Optional[Sequence[ServiceAccountPermissionPermissionArgs]] = None)
    func NewServiceAccountPermission(ctx *Context, name string, args ServiceAccountPermissionArgs, opts ...ResourceOption) (*ServiceAccountPermission, error)
    public ServiceAccountPermission(string name, ServiceAccountPermissionArgs args, CustomResourceOptions? opts = null)
    public ServiceAccountPermission(String name, ServiceAccountPermissionArgs args)
    public ServiceAccountPermission(String name, ServiceAccountPermissionArgs args, CustomResourceOptions options)
    
    type: grafana:ServiceAccountPermission
    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 ServiceAccountPermissionArgs
    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 ServiceAccountPermissionArgs
    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 ServiceAccountPermissionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ServiceAccountPermissionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ServiceAccountPermissionArgs
    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 serviceAccountPermissionResource = new Grafana.ServiceAccountPermission("serviceAccountPermissionResource", new()
    {
        ServiceAccountId = "string",
        OrgId = "string",
        Permissions = new[]
        {
            new Grafana.Inputs.ServiceAccountPermissionPermissionArgs
            {
                Permission = "string",
                TeamId = "string",
                UserId = "string",
            },
        },
    });
    
    example, err := grafana.NewServiceAccountPermission(ctx, "serviceAccountPermissionResource", &grafana.ServiceAccountPermissionArgs{
    	ServiceAccountId: pulumi.String("string"),
    	OrgId:            pulumi.String("string"),
    	Permissions: grafana.ServiceAccountPermissionPermissionArray{
    		&grafana.ServiceAccountPermissionPermissionArgs{
    			Permission: pulumi.String("string"),
    			TeamId:     pulumi.String("string"),
    			UserId:     pulumi.String("string"),
    		},
    	},
    })
    
    var serviceAccountPermissionResource = new ServiceAccountPermission("serviceAccountPermissionResource", ServiceAccountPermissionArgs.builder()
        .serviceAccountId("string")
        .orgId("string")
        .permissions(ServiceAccountPermissionPermissionArgs.builder()
            .permission("string")
            .teamId("string")
            .userId("string")
            .build())
        .build());
    
    service_account_permission_resource = grafana.ServiceAccountPermission("serviceAccountPermissionResource",
        service_account_id="string",
        org_id="string",
        permissions=[grafana.ServiceAccountPermissionPermissionArgs(
            permission="string",
            team_id="string",
            user_id="string",
        )])
    
    const serviceAccountPermissionResource = new grafana.ServiceAccountPermission("serviceAccountPermissionResource", {
        serviceAccountId: "string",
        orgId: "string",
        permissions: [{
            permission: "string",
            teamId: "string",
            userId: "string",
        }],
    });
    
    type: grafana:ServiceAccountPermission
    properties:
        orgId: string
        permissions:
            - permission: string
              teamId: string
              userId: string
        serviceAccountId: string
    

    ServiceAccountPermission Resource Properties

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

    Inputs

    The ServiceAccountPermission resource accepts the following input properties:

    ServiceAccountId string
    The id of the service account.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions List<Pulumiverse.Grafana.Inputs.ServiceAccountPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    ServiceAccountId string
    The id of the service account.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions []ServiceAccountPermissionPermissionArgs
    The permission items to add/update. Items that are omitted from the list will be removed.
    serviceAccountId String
    The id of the service account.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<ServiceAccountPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    serviceAccountId string
    The id of the service account.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions ServiceAccountPermissionPermission[]
    The permission items to add/update. Items that are omitted from the list will be removed.
    service_account_id str
    The id of the service account.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions Sequence[ServiceAccountPermissionPermissionArgs]
    The permission items to add/update. Items that are omitted from the list will be removed.
    serviceAccountId String
    The id of the service account.
    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 ServiceAccountPermission 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 ServiceAccountPermission Resource

    Get an existing ServiceAccountPermission 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?: ServiceAccountPermissionState, opts?: CustomResourceOptions): ServiceAccountPermission
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            org_id: Optional[str] = None,
            permissions: Optional[Sequence[ServiceAccountPermissionPermissionArgs]] = None,
            service_account_id: Optional[str] = None) -> ServiceAccountPermission
    func GetServiceAccountPermission(ctx *Context, name string, id IDInput, state *ServiceAccountPermissionState, opts ...ResourceOption) (*ServiceAccountPermission, error)
    public static ServiceAccountPermission Get(string name, Input<string> id, ServiceAccountPermissionState? state, CustomResourceOptions? opts = null)
    public static ServiceAccountPermission get(String name, Output<String> id, ServiceAccountPermissionState 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:
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions List<Pulumiverse.Grafana.Inputs.ServiceAccountPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    ServiceAccountId string
    The id of the service account.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Permissions []ServiceAccountPermissionPermissionArgs
    The permission items to add/update. Items that are omitted from the list will be removed.
    ServiceAccountId string
    The id of the service account.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions List<ServiceAccountPermissionPermission>
    The permission items to add/update. Items that are omitted from the list will be removed.
    serviceAccountId String
    The id of the service account.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions ServiceAccountPermissionPermission[]
    The permission items to add/update. Items that are omitted from the list will be removed.
    serviceAccountId string
    The id of the service account.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    permissions Sequence[ServiceAccountPermissionPermissionArgs]
    The permission items to add/update. Items that are omitted from the list will be removed.
    service_account_id str
    The id of the service account.
    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.
    serviceAccountId String
    The id of the service account.

    Supporting Types

    ServiceAccountPermissionPermission, ServiceAccountPermissionPermissionArgs

    Permission string
    Permission to associate with item. Must be one of View, Edit, 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. Must be one of View, Edit, 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. Must be one of View, Edit, 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. Must be one of View, Edit, 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. Must be one of View, Edit, 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. Must be one of View, Edit, 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/serviceAccountPermission:ServiceAccountPermission name "{{ serviceAccountID }}"
    
    $ pulumi import grafana:index/serviceAccountPermission:ServiceAccountPermission name "{{ orgID }}:{{ serviceAccountID }}"
    

    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.5.1 published on Wednesday, Jun 12, 2024 by pulumiverse