databricks.PermissionAssignment
Explore with Pulumi AI
These resources are invoked in the workspace context.
Example Usage
In workspace context, adding account-level user to a workspace:
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
// Use the account provider
const me = databricks.getUser({
userName: "me@example.com",
});
const addUser = new databricks.PermissionAssignment("add_user", {
principalId: me.then(me => me.id),
permissions: ["USER"],
});
import pulumi
import pulumi_databricks as databricks
# Use the account provider
me = databricks.get_user(user_name="me@example.com")
add_user = databricks.PermissionAssignment("add_user",
principal_id=me.id,
permissions=["USER"])
package main
import (
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Use the account provider
me, err := databricks.LookupUser(ctx, &databricks.LookupUserArgs{
UserName: pulumi.StringRef("me@example.com"),
}, nil)
if err != nil {
return err
}
_, err = databricks.NewPermissionAssignment(ctx, "add_user", &databricks.PermissionAssignmentArgs{
PrincipalId: pulumi.String(me.Id),
Permissions: pulumi.StringArray{
pulumi.String("USER"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(() =>
{
// Use the account provider
var me = Databricks.GetUser.Invoke(new()
{
UserName = "me@example.com",
});
var addUser = new Databricks.PermissionAssignment("add_user", new()
{
PrincipalId = me.Apply(getUserResult => getUserResult.Id),
Permissions = new[]
{
"USER",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.DatabricksFunctions;
import com.pulumi.databricks.inputs.GetUserArgs;
import com.pulumi.databricks.PermissionAssignment;
import com.pulumi.databricks.PermissionAssignmentArgs;
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) {
// Use the account provider
final var me = DatabricksFunctions.getUser(GetUserArgs.builder()
.userName("me@example.com")
.build());
var addUser = new PermissionAssignment("addUser", PermissionAssignmentArgs.builder()
.principalId(me.applyValue(getUserResult -> getUserResult.id()))
.permissions("USER")
.build());
}
}
resources:
addUser:
type: databricks:PermissionAssignment
name: add_user
properties:
principalId: ${me.id}
permissions:
- USER
variables:
# Use the account provider
me:
fn::invoke:
Function: databricks:getUser
Arguments:
userName: me@example.com
In workspace context, adding account-level service principal to a workspace:
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
// Use the account provider
const sp = databricks.getServicePrincipal({
displayName: "Automation-only SP",
});
const addAdminSpn = new databricks.PermissionAssignment("add_admin_spn", {
principalId: sp.then(sp => sp.id),
permissions: ["ADMIN"],
});
import pulumi
import pulumi_databricks as databricks
# Use the account provider
sp = databricks.get_service_principal(display_name="Automation-only SP")
add_admin_spn = databricks.PermissionAssignment("add_admin_spn",
principal_id=sp.id,
permissions=["ADMIN"])
package main
import (
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Use the account provider
sp, err := databricks.LookupServicePrincipal(ctx, &databricks.LookupServicePrincipalArgs{
DisplayName: pulumi.StringRef("Automation-only SP"),
}, nil)
if err != nil {
return err
}
_, err = databricks.NewPermissionAssignment(ctx, "add_admin_spn", &databricks.PermissionAssignmentArgs{
PrincipalId: pulumi.String(sp.Id),
Permissions: pulumi.StringArray{
pulumi.String("ADMIN"),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(() =>
{
// Use the account provider
var sp = Databricks.GetServicePrincipal.Invoke(new()
{
DisplayName = "Automation-only SP",
});
var addAdminSpn = new Databricks.PermissionAssignment("add_admin_spn", new()
{
PrincipalId = sp.Apply(getServicePrincipalResult => getServicePrincipalResult.Id),
Permissions = new[]
{
"ADMIN",
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.DatabricksFunctions;
import com.pulumi.databricks.inputs.GetServicePrincipalArgs;
import com.pulumi.databricks.PermissionAssignment;
import com.pulumi.databricks.PermissionAssignmentArgs;
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) {
// Use the account provider
final var sp = DatabricksFunctions.getServicePrincipal(GetServicePrincipalArgs.builder()
.displayName("Automation-only SP")
.build());
var addAdminSpn = new PermissionAssignment("addAdminSpn", PermissionAssignmentArgs.builder()
.principalId(sp.applyValue(getServicePrincipalResult -> getServicePrincipalResult.id()))
.permissions("ADMIN")
.build());
}
}
resources:
addAdminSpn:
type: databricks:PermissionAssignment
name: add_admin_spn
properties:
principalId: ${sp.id}
permissions:
- ADMIN
variables:
# Use the account provider
sp:
fn::invoke:
Function: databricks:getServicePrincipal
Arguments:
displayName: Automation-only SP
In workspace context, adding account-level group to a workspace:
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
// Use the account provider
const accountLevel = databricks.getGroup({
displayName: "example-group",
});
// Use the workspace provider
const _this = new databricks.PermissionAssignment("this", {
principalId: accountLevel.then(accountLevel => accountLevel.id),
permissions: ["USER"],
});
const workspaceLevel = databricks.getGroup({
displayName: "example-group",
});
export const databricksGroupId = workspaceLevel.then(workspaceLevel => workspaceLevel.id);
import pulumi
import pulumi_databricks as databricks
# Use the account provider
account_level = databricks.get_group(display_name="example-group")
# Use the workspace provider
this = databricks.PermissionAssignment("this",
principal_id=account_level.id,
permissions=["USER"])
workspace_level = databricks.get_group(display_name="example-group")
pulumi.export("databricksGroupId", workspace_level.id)
package main
import (
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Use the account provider
accountLevel, err := databricks.LookupGroup(ctx, &databricks.LookupGroupArgs{
DisplayName: "example-group",
}, nil)
if err != nil {
return err
}
// Use the workspace provider
_, err = databricks.NewPermissionAssignment(ctx, "this", &databricks.PermissionAssignmentArgs{
PrincipalId: pulumi.String(accountLevel.Id),
Permissions: pulumi.StringArray{
pulumi.String("USER"),
},
})
if err != nil {
return err
}
workspaceLevel, err := databricks.LookupGroup(ctx, &databricks.LookupGroupArgs{
DisplayName: "example-group",
}, nil)
if err != nil {
return err
}
ctx.Export("databricksGroupId", workspaceLevel.Id)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(() =>
{
// Use the account provider
var accountLevel = Databricks.GetGroup.Invoke(new()
{
DisplayName = "example-group",
});
// Use the workspace provider
var @this = new Databricks.PermissionAssignment("this", new()
{
PrincipalId = accountLevel.Apply(getGroupResult => getGroupResult.Id),
Permissions = new[]
{
"USER",
},
});
var workspaceLevel = Databricks.GetGroup.Invoke(new()
{
DisplayName = "example-group",
});
return new Dictionary<string, object?>
{
["databricksGroupId"] = workspaceLevel.Apply(getGroupResult => getGroupResult.Id),
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.DatabricksFunctions;
import com.pulumi.databricks.inputs.GetGroupArgs;
import com.pulumi.databricks.PermissionAssignment;
import com.pulumi.databricks.PermissionAssignmentArgs;
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) {
// Use the account provider
final var accountLevel = DatabricksFunctions.getGroup(GetGroupArgs.builder()
.displayName("example-group")
.build());
// Use the workspace provider
var this_ = new PermissionAssignment("this", PermissionAssignmentArgs.builder()
.principalId(accountLevel.applyValue(getGroupResult -> getGroupResult.id()))
.permissions("USER")
.build());
final var workspaceLevel = DatabricksFunctions.getGroup(GetGroupArgs.builder()
.displayName("example-group")
.build());
ctx.export("databricksGroupId", workspaceLevel.applyValue(getGroupResult -> getGroupResult.id()));
}
}
resources:
# Use the workspace provider
this:
type: databricks:PermissionAssignment
properties:
principalId: ${accountLevel.id}
permissions:
- USER
variables:
# Use the account provider
accountLevel:
fn::invoke:
Function: databricks:getGroup
Arguments:
displayName: example-group
workspaceLevel:
fn::invoke:
Function: databricks:getGroup
Arguments:
displayName: example-group
outputs:
databricksGroupId: ${workspaceLevel.id}
Related Resources
The following resources are used in the same context:
- databricks.Group to manage groups in Databricks Workspace or Account Console (for AWS deployments).
- databricks.Group data to retrieve information about databricks.Group members, entitlements and instance profiles.
- databricks.GroupMember to attach users and groups as group members.
- databricks.MwsPermissionAssignment to manage permission assignment from an account context
Create PermissionAssignment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new PermissionAssignment(name: string, args: PermissionAssignmentArgs, opts?: CustomResourceOptions);
@overload
def PermissionAssignment(resource_name: str,
args: PermissionAssignmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def PermissionAssignment(resource_name: str,
opts: Optional[ResourceOptions] = None,
permissions: Optional[Sequence[str]] = None,
principal_id: Optional[str] = None)
func NewPermissionAssignment(ctx *Context, name string, args PermissionAssignmentArgs, opts ...ResourceOption) (*PermissionAssignment, error)
public PermissionAssignment(string name, PermissionAssignmentArgs args, CustomResourceOptions? opts = null)
public PermissionAssignment(String name, PermissionAssignmentArgs args)
public PermissionAssignment(String name, PermissionAssignmentArgs args, CustomResourceOptions options)
type: databricks:PermissionAssignment
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 PermissionAssignmentArgs
- 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 PermissionAssignmentArgs
- 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 PermissionAssignmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PermissionAssignmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args PermissionAssignmentArgs
- 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 permissionAssignmentResource = new Databricks.PermissionAssignment("permissionAssignmentResource", new()
{
Permissions = new[]
{
"string",
},
PrincipalId = "string",
});
example, err := databricks.NewPermissionAssignment(ctx, "permissionAssignmentResource", &databricks.PermissionAssignmentArgs{
Permissions: pulumi.StringArray{
pulumi.String("string"),
},
PrincipalId: pulumi.String("string"),
})
var permissionAssignmentResource = new PermissionAssignment("permissionAssignmentResource", PermissionAssignmentArgs.builder()
.permissions("string")
.principalId("string")
.build());
permission_assignment_resource = databricks.PermissionAssignment("permissionAssignmentResource",
permissions=["string"],
principal_id="string")
const permissionAssignmentResource = new databricks.PermissionAssignment("permissionAssignmentResource", {
permissions: ["string"],
principalId: "string",
});
type: databricks:PermissionAssignment
properties:
permissions:
- string
principalId: string
PermissionAssignment 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 PermissionAssignment resource accepts the following input properties:
- Permissions List<string>
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- Principal
Id string - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- Permissions []string
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- Principal
Id string - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions List<String>
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal
Id String - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions string[]
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal
Id string - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions Sequence[str]
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal_
id str - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions List<String>
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal
Id String - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
Outputs
All input properties are implicitly available as output properties. Additionally, the PermissionAssignment 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 PermissionAssignment Resource
Get an existing PermissionAssignment 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?: PermissionAssignmentState, opts?: CustomResourceOptions): PermissionAssignment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
permissions: Optional[Sequence[str]] = None,
principal_id: Optional[str] = None) -> PermissionAssignment
func GetPermissionAssignment(ctx *Context, name string, id IDInput, state *PermissionAssignmentState, opts ...ResourceOption) (*PermissionAssignment, error)
public static PermissionAssignment Get(string name, Input<string> id, PermissionAssignmentState? state, CustomResourceOptions? opts = null)
public static PermissionAssignment get(String name, Output<String> id, PermissionAssignmentState 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.
- Permissions List<string>
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- Principal
Id string - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- Permissions []string
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- Principal
Id string - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions List<String>
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal
Id String - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions string[]
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal
Id string - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions Sequence[str]
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal_
id str - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
- permissions List<String>
- The list of workspace permissions to assign to the principal:
"USER"
- Can access the workspace with basic privileges."ADMIN"
- Can access the workspace and has workspace admin privileges to manage users and groups, workspace configurations, and more.
- principal
Id String - Databricks ID of the user, service principal, or group. The principal ID can be retrieved using the account-level SCIM API, or using databricks_user, databricks.ServicePrincipal or databricks.Group data sources with account API (and has to be an account admin). A more sensible approach is to retrieve the list of
principal_id
as outputs from another Pulumi stack.
Import
The resource databricks_permission_assignment
can be imported using the principal id
bash
$ pulumi import databricks:index/permissionAssignment:PermissionAssignment this principal_id
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- databricks pulumi/pulumi-databricks
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
databricks
Terraform Provider.