prefect.WorkspaceAccess
Explore with Pulumi AI
The resource workspace_access represents a connection between an accessor (User, Service Account or Team) with a Workspace Role. This resource specifies an actor’s access level to a specific Workspace in the Account.
Use this resource in conjunction with the workspace_role resource or data source to manage access to Workspaces.
For more information, see manage workspaces.
This feature is available in the following product plan(s): Prefect Cloud (Pro), Prefect Cloud (Enterprise).
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as prefect from "@pulumi/prefect";
const developer = prefect.getWorkspaceRole({
    name: "Developer",
});
const marvin = prefect.getAccountMember({
    email: "marvin@prefect.io",
});
// Assign the Workspace Role to the Account Member
const marvinDeveloper = new prefect.WorkspaceAccess("marvinDeveloper", {
    accessorType: "USER",
    accessorId: prefect_account_member.marvin.user_id,
    workspaceId: "00000000-0000-0000-0000-000000000000",
    workspaceRoleId: developer.then(developer => developer.id),
});
// ASSIGNING WORKSPACE ACCESS TO A SERVICE ACCOUNT
// Create a Service Account resource
const bot = new prefect.ServiceAccount("bot", {});
// Assign the Workspace Role to the Service Account
const botDeveloper = new prefect.WorkspaceAccess("botDeveloper", {
    accessorType: "SERVICE_ACCOUNT",
    accessorId: bot.id,
    workspaceId: "00000000-0000-0000-0000-000000000000",
    workspaceRoleId: developer.then(developer => developer.id),
});
// ASSIGNING WORKSPACE ACCESS TO A TEAM
// Assign the Workspace Role to the Team
const teamDeveloper = new prefect.WorkspaceAccess("teamDeveloper", {
    accessorType: "TEAM",
    accessorId: "11111111-1111-1111-1111-111111111111",
    workspaceId: "00000000-0000-0000-0000-000000000000",
    workspaceRoleId: developer.then(developer => developer.id),
});
import pulumi
import pulumi_prefect as prefect
developer = prefect.get_workspace_role(name="Developer")
marvin = prefect.get_account_member(email="marvin@prefect.io")
# Assign the Workspace Role to the Account Member
marvin_developer = prefect.WorkspaceAccess("marvinDeveloper",
    accessor_type="USER",
    accessor_id=prefect_account_member["marvin"]["user_id"],
    workspace_id="00000000-0000-0000-0000-000000000000",
    workspace_role_id=developer.id)
# ASSIGNING WORKSPACE ACCESS TO A SERVICE ACCOUNT
# Create a Service Account resource
bot = prefect.ServiceAccount("bot")
# Assign the Workspace Role to the Service Account
bot_developer = prefect.WorkspaceAccess("botDeveloper",
    accessor_type="SERVICE_ACCOUNT",
    accessor_id=bot.id,
    workspace_id="00000000-0000-0000-0000-000000000000",
    workspace_role_id=developer.id)
# ASSIGNING WORKSPACE ACCESS TO A TEAM
# Assign the Workspace Role to the Team
team_developer = prefect.WorkspaceAccess("teamDeveloper",
    accessor_type="TEAM",
    accessor_id="11111111-1111-1111-1111-111111111111",
    workspace_id="00000000-0000-0000-0000-000000000000",
    workspace_role_id=developer.id)
package main
import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/prefect/v2/prefect"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		developer, err := prefect.LookupWorkspaceRole(ctx, &prefect.LookupWorkspaceRoleArgs{
			Name: "Developer",
		}, nil)
		if err != nil {
			return err
		}
		_, err = prefect.LookupAccountMember(ctx, &prefect.LookupAccountMemberArgs{
			Email: "marvin@prefect.io",
		}, nil)
		if err != nil {
			return err
		}
		// Assign the Workspace Role to the Account Member
		_, err = prefect.NewWorkspaceAccess(ctx, "marvinDeveloper", &prefect.WorkspaceAccessArgs{
			AccessorType:    pulumi.String("USER"),
			AccessorId:      pulumi.Any(prefect_account_member.Marvin.User_id),
			WorkspaceId:     pulumi.String("00000000-0000-0000-0000-000000000000"),
			WorkspaceRoleId: pulumi.String(developer.Id),
		})
		if err != nil {
			return err
		}
		// ASSIGNING WORKSPACE ACCESS TO A SERVICE ACCOUNT
		// Create a Service Account resource
		bot, err := prefect.NewServiceAccount(ctx, "bot", nil)
		if err != nil {
			return err
		}
		// Assign the Workspace Role to the Service Account
		_, err = prefect.NewWorkspaceAccess(ctx, "botDeveloper", &prefect.WorkspaceAccessArgs{
			AccessorType:    pulumi.String("SERVICE_ACCOUNT"),
			AccessorId:      bot.ID(),
			WorkspaceId:     pulumi.String("00000000-0000-0000-0000-000000000000"),
			WorkspaceRoleId: pulumi.String(developer.Id),
		})
		if err != nil {
			return err
		}
		// Assign the Workspace Role to the Team
		_, err = prefect.NewWorkspaceAccess(ctx, "teamDeveloper", &prefect.WorkspaceAccessArgs{
			AccessorType:    pulumi.String("TEAM"),
			AccessorId:      pulumi.String("11111111-1111-1111-1111-111111111111"),
			WorkspaceId:     pulumi.String("00000000-0000-0000-0000-000000000000"),
			WorkspaceRoleId: pulumi.String(developer.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Prefect = Pulumi.Prefect;
return await Deployment.RunAsync(() => 
{
    var developer = Prefect.GetWorkspaceRole.Invoke(new()
    {
        Name = "Developer",
    });
    var marvin = Prefect.GetAccountMember.Invoke(new()
    {
        Email = "marvin@prefect.io",
    });
    // Assign the Workspace Role to the Account Member
    var marvinDeveloper = new Prefect.WorkspaceAccess("marvinDeveloper", new()
    {
        AccessorType = "USER",
        AccessorId = prefect_account_member.Marvin.User_id,
        WorkspaceId = "00000000-0000-0000-0000-000000000000",
        WorkspaceRoleId = developer.Apply(getWorkspaceRoleResult => getWorkspaceRoleResult.Id),
    });
    // ASSIGNING WORKSPACE ACCESS TO A SERVICE ACCOUNT
    // Create a Service Account resource
    var bot = new Prefect.ServiceAccount("bot");
    // Assign the Workspace Role to the Service Account
    var botDeveloper = new Prefect.WorkspaceAccess("botDeveloper", new()
    {
        AccessorType = "SERVICE_ACCOUNT",
        AccessorId = bot.Id,
        WorkspaceId = "00000000-0000-0000-0000-000000000000",
        WorkspaceRoleId = developer.Apply(getWorkspaceRoleResult => getWorkspaceRoleResult.Id),
    });
    // ASSIGNING WORKSPACE ACCESS TO A TEAM
    // Assign the Workspace Role to the Team
    var teamDeveloper = new Prefect.WorkspaceAccess("teamDeveloper", new()
    {
        AccessorType = "TEAM",
        AccessorId = "11111111-1111-1111-1111-111111111111",
        WorkspaceId = "00000000-0000-0000-0000-000000000000",
        WorkspaceRoleId = developer.Apply(getWorkspaceRoleResult => getWorkspaceRoleResult.Id),
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.prefect.PrefectFunctions;
import com.pulumi.prefect.inputs.GetWorkspaceRoleArgs;
import com.pulumi.prefect.inputs.GetAccountMemberArgs;
import com.pulumi.prefect.WorkspaceAccess;
import com.pulumi.prefect.WorkspaceAccessArgs;
import com.pulumi.prefect.ServiceAccount;
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) {
        final var developer = PrefectFunctions.getWorkspaceRole(GetWorkspaceRoleArgs.builder()
            .name("Developer")
            .build());
        final var marvin = PrefectFunctions.getAccountMember(GetAccountMemberArgs.builder()
            .email("marvin@prefect.io")
            .build());
        // Assign the Workspace Role to the Account Member
        var marvinDeveloper = new WorkspaceAccess("marvinDeveloper", WorkspaceAccessArgs.builder()
            .accessorType("USER")
            .accessorId(prefect_account_member.marvin().user_id())
            .workspaceId("00000000-0000-0000-0000-000000000000")
            .workspaceRoleId(developer.applyValue(getWorkspaceRoleResult -> getWorkspaceRoleResult.id()))
            .build());
        // ASSIGNING WORKSPACE ACCESS TO A SERVICE ACCOUNT
        // Create a Service Account resource
        var bot = new ServiceAccount("bot");
        // Assign the Workspace Role to the Service Account
        var botDeveloper = new WorkspaceAccess("botDeveloper", WorkspaceAccessArgs.builder()
            .accessorType("SERVICE_ACCOUNT")
            .accessorId(bot.id())
            .workspaceId("00000000-0000-0000-0000-000000000000")
            .workspaceRoleId(developer.applyValue(getWorkspaceRoleResult -> getWorkspaceRoleResult.id()))
            .build());
        // ASSIGNING WORKSPACE ACCESS TO A TEAM
        // Assign the Workspace Role to the Team
        var teamDeveloper = new WorkspaceAccess("teamDeveloper", WorkspaceAccessArgs.builder()
            .accessorType("TEAM")
            .accessorId("11111111-1111-1111-1111-111111111111")
            .workspaceId("00000000-0000-0000-0000-000000000000")
            .workspaceRoleId(developer.applyValue(getWorkspaceRoleResult -> getWorkspaceRoleResult.id()))
            .build());
    }
}
resources:
  # Assign the Workspace Role to the Account Member
  marvinDeveloper:
    type: prefect:WorkspaceAccess
    properties:
      accessorType: USER
      accessorId: ${prefect_account_member.marvin.user_id}
      workspaceId: 00000000-0000-0000-0000-000000000000
      workspaceRoleId: ${developer.id}
  # ASSIGNING WORKSPACE ACCESS TO A SERVICE ACCOUNT
  # Create a Service Account resource
  bot:
    type: prefect:ServiceAccount
  # Assign the Workspace Role to the Service Account
  botDeveloper: # ASSIGNING WORKSPACE ACCESS TO A TEAM
    type: prefect:WorkspaceAccess
    properties:
      accessorType: SERVICE_ACCOUNT
      accessorId: ${bot.id}
      workspaceId: 00000000-0000-0000-0000-000000000000
      workspaceRoleId: ${developer.id}
  # Assign the Workspace Role to the Team
  teamDeveloper:
    type: prefect:WorkspaceAccess
    properties:
      accessorType: TEAM
      accessorId: 11111111-1111-1111-1111-111111111111
      workspaceId: 00000000-0000-0000-0000-000000000000
      workspaceRoleId: ${developer.id}
variables:
  developer:
    fn::invoke:
      function: prefect:getWorkspaceRole
      arguments:
        name: Developer
  marvin:
    fn::invoke:
      function: prefect:getAccountMember
      arguments:
        email: marvin@prefect.io
Create WorkspaceAccess Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new WorkspaceAccess(name: string, args: WorkspaceAccessArgs, opts?: CustomResourceOptions);@overload
def WorkspaceAccess(resource_name: str,
                    args: WorkspaceAccessArgs,
                    opts: Optional[ResourceOptions] = None)
@overload
def WorkspaceAccess(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    accessor_id: Optional[str] = None,
                    accessor_type: Optional[str] = None,
                    workspace_role_id: Optional[str] = None,
                    account_id: Optional[str] = None,
                    workspace_id: Optional[str] = None)func NewWorkspaceAccess(ctx *Context, name string, args WorkspaceAccessArgs, opts ...ResourceOption) (*WorkspaceAccess, error)public WorkspaceAccess(string name, WorkspaceAccessArgs args, CustomResourceOptions? opts = null)
public WorkspaceAccess(String name, WorkspaceAccessArgs args)
public WorkspaceAccess(String name, WorkspaceAccessArgs args, CustomResourceOptions options)
type: prefect:WorkspaceAccess
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 WorkspaceAccessArgs
- 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 WorkspaceAccessArgs
- 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 WorkspaceAccessArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args WorkspaceAccessArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args WorkspaceAccessArgs
- 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 workspaceAccessResource = new Prefect.WorkspaceAccess("workspaceAccessResource", new()
{
    AccessorId = "string",
    AccessorType = "string",
    WorkspaceRoleId = "string",
    AccountId = "string",
    WorkspaceId = "string",
});
example, err := prefect.NewWorkspaceAccess(ctx, "workspaceAccessResource", &prefect.WorkspaceAccessArgs{
	AccessorId:      pulumi.String("string"),
	AccessorType:    pulumi.String("string"),
	WorkspaceRoleId: pulumi.String("string"),
	AccountId:       pulumi.String("string"),
	WorkspaceId:     pulumi.String("string"),
})
var workspaceAccessResource = new WorkspaceAccess("workspaceAccessResource", WorkspaceAccessArgs.builder()
    .accessorId("string")
    .accessorType("string")
    .workspaceRoleId("string")
    .accountId("string")
    .workspaceId("string")
    .build());
workspace_access_resource = prefect.WorkspaceAccess("workspaceAccessResource",
    accessor_id="string",
    accessor_type="string",
    workspace_role_id="string",
    account_id="string",
    workspace_id="string")
const workspaceAccessResource = new prefect.WorkspaceAccess("workspaceAccessResource", {
    accessorId: "string",
    accessorType: "string",
    workspaceRoleId: "string",
    accountId: "string",
    workspaceId: "string",
});
type: prefect:WorkspaceAccess
properties:
    accessorId: string
    accessorType: string
    accountId: string
    workspaceId: string
    workspaceRoleId: string
WorkspaceAccess 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 WorkspaceAccess resource accepts the following input properties:
- AccessorId string
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- AccessorType string
- USER | SERVICE_ACCOUNT | TEAM
- WorkspaceRole stringId 
- Workspace Role ID (UUID) to grant to accessor
- AccountId string
- Account ID (UUID) where the workspace is located
- WorkspaceId string
- Workspace ID (UUID) to grant access to
- AccessorId string
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- AccessorType string
- USER | SERVICE_ACCOUNT | TEAM
- WorkspaceRole stringId 
- Workspace Role ID (UUID) to grant to accessor
- AccountId string
- Account ID (UUID) where the workspace is located
- WorkspaceId string
- Workspace ID (UUID) to grant access to
- accessorId String
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessorType String
- USER | SERVICE_ACCOUNT | TEAM
- workspaceRole StringId 
- Workspace Role ID (UUID) to grant to accessor
- accountId String
- Account ID (UUID) where the workspace is located
- workspaceId String
- Workspace ID (UUID) to grant access to
- accessorId string
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessorType string
- USER | SERVICE_ACCOUNT | TEAM
- workspaceRole stringId 
- Workspace Role ID (UUID) to grant to accessor
- accountId string
- Account ID (UUID) where the workspace is located
- workspaceId string
- Workspace ID (UUID) to grant access to
- accessor_id str
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessor_type str
- USER | SERVICE_ACCOUNT | TEAM
- workspace_role_ strid 
- Workspace Role ID (UUID) to grant to accessor
- account_id str
- Account ID (UUID) where the workspace is located
- workspace_id str
- Workspace ID (UUID) to grant access to
- accessorId String
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessorType String
- USER | SERVICE_ACCOUNT | TEAM
- workspaceRole StringId 
- Workspace Role ID (UUID) to grant to accessor
- accountId String
- Account ID (UUID) where the workspace is located
- workspaceId String
- Workspace ID (UUID) to grant access to
Outputs
All input properties are implicitly available as output properties. Additionally, the WorkspaceAccess 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 WorkspaceAccess Resource
Get an existing WorkspaceAccess 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?: WorkspaceAccessState, opts?: CustomResourceOptions): WorkspaceAccess@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        accessor_id: Optional[str] = None,
        accessor_type: Optional[str] = None,
        account_id: Optional[str] = None,
        workspace_id: Optional[str] = None,
        workspace_role_id: Optional[str] = None) -> WorkspaceAccessfunc GetWorkspaceAccess(ctx *Context, name string, id IDInput, state *WorkspaceAccessState, opts ...ResourceOption) (*WorkspaceAccess, error)public static WorkspaceAccess Get(string name, Input<string> id, WorkspaceAccessState? state, CustomResourceOptions? opts = null)public static WorkspaceAccess get(String name, Output<String> id, WorkspaceAccessState state, CustomResourceOptions options)resources:  _:    type: prefect:WorkspaceAccess    get:      id: ${id}- 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.
- AccessorId string
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- AccessorType string
- USER | SERVICE_ACCOUNT | TEAM
- AccountId string
- Account ID (UUID) where the workspace is located
- WorkspaceId string
- Workspace ID (UUID) to grant access to
- WorkspaceRole stringId 
- Workspace Role ID (UUID) to grant to accessor
- AccessorId string
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- AccessorType string
- USER | SERVICE_ACCOUNT | TEAM
- AccountId string
- Account ID (UUID) where the workspace is located
- WorkspaceId string
- Workspace ID (UUID) to grant access to
- WorkspaceRole stringId 
- Workspace Role ID (UUID) to grant to accessor
- accessorId String
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessorType String
- USER | SERVICE_ACCOUNT | TEAM
- accountId String
- Account ID (UUID) where the workspace is located
- workspaceId String
- Workspace ID (UUID) to grant access to
- workspaceRole StringId 
- Workspace Role ID (UUID) to grant to accessor
- accessorId string
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessorType string
- USER | SERVICE_ACCOUNT | TEAM
- accountId string
- Account ID (UUID) where the workspace is located
- workspaceId string
- Workspace ID (UUID) to grant access to
- workspaceRole stringId 
- Workspace Role ID (UUID) to grant to accessor
- accessor_id str
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessor_type str
- USER | SERVICE_ACCOUNT | TEAM
- account_id str
- Account ID (UUID) where the workspace is located
- workspace_id str
- Workspace ID (UUID) to grant access to
- workspace_role_ strid 
- Workspace Role ID (UUID) to grant to accessor
- accessorId String
- ID (UUID) of accessor to the workspace. This can be an account_member.user_idorservice_account.id
- accessorType String
- USER | SERVICE_ACCOUNT | TEAM
- accountId String
- Account ID (UUID) where the workspace is located
- workspaceId String
- Workspace ID (UUID) to grant access to
- workspaceRole StringId 
- Workspace Role ID (UUID) to grant to accessor
Package Details
- Repository
- prefect prefecthq/terraform-provider-prefect
- License
- Notes
- This Pulumi package is based on the prefectTerraform Provider.