1. Packages
  2. Packages
  3. Gitlab Provider
  4. API Docs
  5. ProjectServiceAccount
Viewing docs for GitLab v10.0.0
published on Friday, Jun 26, 2026 by Pulumi
gitlab logo
Viewing docs for GitLab v10.0.0
published on Friday, Jun 26, 2026 by Pulumi

    The gitlab.ProjectServiceAccount resource allows creating a GitLab project service account.

    Upstream API: GitLab REST API docs

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as gitlab from "@pulumi/gitlab";
    
    const example = new gitlab.Project("example", {
        name: "example",
        description: "An example project",
    });
    // The service account against the project
    const exampleSa = new gitlab.ProjectServiceAccount("example_sa", {
        project: example.id,
        name: "example-name",
        username: "example-username",
    });
    // To assign the service account to a project as a member
    const exampleMembership = new gitlab.ProjectMembership("example_membership", {
        project: example.id,
        userId: exampleSa.serviceAccountId.apply(x =>Number(x)),
        accessLevel: "developer",
        expiresAt: "2020-03-14",
    });
    
    import pulumi
    import pulumi_gitlab as gitlab
    
    example = gitlab.Project("example",
        name="example",
        description="An example project")
    # The service account against the project
    example_sa = gitlab.ProjectServiceAccount("example_sa",
        project=example.id,
        name="example-name",
        username="example-username")
    # To assign the service account to a project as a member
    example_membership = gitlab.ProjectMembership("example_membership",
        project=example.id,
        user_id=example_sa.service_account_id.apply(lambda x: int(x)),
        access_level="developer",
        expires_at="2020-03-14")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gitlab/sdk/v10/go/gitlab"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := gitlab.NewProject(ctx, "example", &gitlab.ProjectArgs{
    			Name:        pulumi.String("example"),
    			Description: pulumi.String("An example project"),
    		})
    		if err != nil {
    			return err
    		}
    		// The service account against the project
    		exampleSa, err := gitlab.NewProjectServiceAccount(ctx, "example_sa", &gitlab.ProjectServiceAccountArgs{
    			Project:  example.ID(),
    			Name:     pulumi.String("example-name"),
    			Username: pulumi.String("example-username"),
    		})
    		if err != nil {
    			return err
    		}
    		// To assign the service account to a project as a member
    		_, err = gitlab.NewProjectMembership(ctx, "example_membership", &gitlab.ProjectMembershipArgs{
    			Project:     example.ID(),
    			UserId:      exampleSa.ServiceAccountId,
    			AccessLevel: pulumi.String("developer"),
    			ExpiresAt:   pulumi.String("2020-03-14"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using GitLab = Pulumi.GitLab;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new GitLab.Project("example", new()
        {
            Name = "example",
            Description = "An example project",
        });
    
        // The service account against the project
        var exampleSa = new GitLab.ProjectServiceAccount("example_sa", new()
        {
            Project = example.Id,
            Name = "example-name",
            Username = "example-username",
        });
    
        // To assign the service account to a project as a member
        var exampleMembership = new GitLab.ProjectMembership("example_membership", new()
        {
            Project = example.Id,
            UserId = exampleSa.ServiceAccountId,
            AccessLevel = "developer",
            ExpiresAt = "2020-03-14",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.gitlab.Project;
    import com.pulumi.gitlab.ProjectArgs;
    import com.pulumi.gitlab.ProjectServiceAccount;
    import com.pulumi.gitlab.ProjectServiceAccountArgs;
    import com.pulumi.gitlab.ProjectMembership;
    import com.pulumi.gitlab.ProjectMembershipArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 example = new Project("example", ProjectArgs.builder()
                .name("example")
                .description("An example project")
                .build());
    
            // The service account against the project
            var exampleSa = new ProjectServiceAccount("exampleSa", ProjectServiceAccountArgs.builder()
                .project(example.id())
                .name("example-name")
                .username("example-username")
                .build());
    
            // To assign the service account to a project as a member
            var exampleMembership = new ProjectMembership("exampleMembership", ProjectMembershipArgs.builder()
                .project(example.id())
                .userId(exampleSa.serviceAccountId())
                .accessLevel("developer")
                .expiresAt("2020-03-14")
                .build());
    
        }
    }
    
    resources:
      example:
        type: gitlab:Project
        properties:
          name: example
          description: An example project
      # The service account against the project
      exampleSa:
        type: gitlab:ProjectServiceAccount
        name: example_sa
        properties:
          project: ${example.id}
          name: example-name
          username: example-username
      # To assign the service account to a project as a member
      exampleMembership:
        type: gitlab:ProjectMembership
        name: example_membership
        properties:
          project: ${example.id}
          userId: ${exampleSa.serviceAccountId}
          accessLevel: developer
          expiresAt: 2020-03-14
    
    pulumi {
      required_providers {
        gitlab = {
          source = "pulumi/gitlab"
        }
      }
    }
    
    resource "gitlab_project" "example" {
      name        = "example"
      description = "An example project"
    }
    # The service account against the project
    resource "gitlab_projectserviceaccount" "example_sa" {
      project  = gitlab_project.example.id
      name     = "example-name"
      username = "example-username"
    }
    # To assign the service account to a project as a member
    resource "gitlab_projectmembership" "example_membership" {
      project      = gitlab_project.example.id
      user_id      = gitlab_projectserviceaccount.example_sa.service_account_id
      access_level = "developer"
      expires_at   = "2020-03-14"
    }
    

    Create ProjectServiceAccount Resource

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

    Constructor syntax

    new ProjectServiceAccount(name: string, args: ProjectServiceAccountArgs, opts?: CustomResourceOptions);
    @overload
    def ProjectServiceAccount(resource_name: str,
                              args: ProjectServiceAccountArgs,
                              opts: Optional[ResourceOptions] = None)
    
    @overload
    def ProjectServiceAccount(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              project: Optional[str] = None,
                              email: Optional[str] = None,
                              name: Optional[str] = None,
                              skip_wait_for_deletion: Optional[bool] = None,
                              timeouts: Optional[ProjectServiceAccountTimeoutsArgs] = None,
                              username: Optional[str] = None)
    func NewProjectServiceAccount(ctx *Context, name string, args ProjectServiceAccountArgs, opts ...ResourceOption) (*ProjectServiceAccount, error)
    public ProjectServiceAccount(string name, ProjectServiceAccountArgs args, CustomResourceOptions? opts = null)
    public ProjectServiceAccount(String name, ProjectServiceAccountArgs args)
    public ProjectServiceAccount(String name, ProjectServiceAccountArgs args, CustomResourceOptions options)
    
    type: gitlab:ProjectServiceAccount
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "gitlab_projectserviceaccount" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args ProjectServiceAccountArgs
    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 ProjectServiceAccountArgs
    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 ProjectServiceAccountArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ProjectServiceAccountArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ProjectServiceAccountArgs
    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 projectServiceAccountResource = new GitLab.ProjectServiceAccount("projectServiceAccountResource", new()
    {
        Project = "string",
        Email = "string",
        Name = "string",
        SkipWaitForDeletion = false,
        Timeouts = new GitLab.Inputs.ProjectServiceAccountTimeoutsArgs
        {
            Delete = "string",
        },
        Username = "string",
    });
    
    example, err := gitlab.NewProjectServiceAccount(ctx, "projectServiceAccountResource", &gitlab.ProjectServiceAccountArgs{
    	Project:             pulumi.String("string"),
    	Email:               pulumi.String("string"),
    	Name:                pulumi.String("string"),
    	SkipWaitForDeletion: pulumi.Bool(false),
    	Timeouts: &gitlab.ProjectServiceAccountTimeoutsArgs{
    		Delete: pulumi.String("string"),
    	},
    	Username: pulumi.String("string"),
    })
    
    resource "gitlab_projectserviceaccount" "projectServiceAccountResource" {
      project                = "string"
      email                  = "string"
      name                   = "string"
      skip_wait_for_deletion = false
      timeouts = {
        delete = "string"
      }
      username = "string"
    }
    
    var projectServiceAccountResource = new ProjectServiceAccount("projectServiceAccountResource", ProjectServiceAccountArgs.builder()
        .project("string")
        .email("string")
        .name("string")
        .skipWaitForDeletion(false)
        .timeouts(ProjectServiceAccountTimeoutsArgs.builder()
            .delete("string")
            .build())
        .username("string")
        .build());
    
    project_service_account_resource = gitlab.ProjectServiceAccount("projectServiceAccountResource",
        project="string",
        email="string",
        name="string",
        skip_wait_for_deletion=False,
        timeouts={
            "delete": "string",
        },
        username="string")
    
    const projectServiceAccountResource = new gitlab.ProjectServiceAccount("projectServiceAccountResource", {
        project: "string",
        email: "string",
        name: "string",
        skipWaitForDeletion: false,
        timeouts: {
            "delete": "string",
        },
        username: "string",
    });
    
    type: gitlab:ProjectServiceAccount
    properties:
        email: string
        name: string
        project: string
        skipWaitForDeletion: false
        timeouts:
            delete: string
        username: string
    

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

    Project string
    The ID or URL-encoded path of the project that the service account is created in.
    Email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    Name string
    The name of the user. If not specified, the default Service account user name is used.
    SkipWaitForDeletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    Timeouts Pulumi.GitLab.Inputs.ProjectServiceAccountTimeouts
    Username string
    The username of the user. If not specified, it’s automatically generated.
    Project string
    The ID or URL-encoded path of the project that the service account is created in.
    Email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    Name string
    The name of the user. If not specified, the default Service account user name is used.
    SkipWaitForDeletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    Timeouts ProjectServiceAccountTimeoutsArgs
    Username string
    The username of the user. If not specified, it’s automatically generated.
    project string
    The ID or URL-encoded path of the project that the service account is created in.
    email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name string
    The name of the user. If not specified, the default Service account user name is used.
    skip_wait_for_deletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts object
    username string
    The username of the user. If not specified, it’s automatically generated.
    project String
    The ID or URL-encoded path of the project that the service account is created in.
    email String
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name String
    The name of the user. If not specified, the default Service account user name is used.
    skipWaitForDeletion Boolean
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts ProjectServiceAccountTimeouts
    username String
    The username of the user. If not specified, it’s automatically generated.
    project string
    The ID or URL-encoded path of the project that the service account is created in.
    email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name string
    The name of the user. If not specified, the default Service account user name is used.
    skipWaitForDeletion boolean
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts ProjectServiceAccountTimeouts
    username string
    The username of the user. If not specified, it’s automatically generated.
    project str
    The ID or URL-encoded path of the project that the service account is created in.
    email str
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name str
    The name of the user. If not specified, the default Service account user name is used.
    skip_wait_for_deletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts ProjectServiceAccountTimeoutsArgs
    username str
    The username of the user. If not specified, it’s automatically generated.
    project String
    The ID or URL-encoded path of the project that the service account is created in.
    email String
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name String
    The name of the user. If not specified, the default Service account user name is used.
    skipWaitForDeletion Boolean
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts Property Map
    username String
    The username of the user. If not specified, it’s automatically generated.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ProjectServiceAccount resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    ServiceAccountId string
    The service account id.
    Id string
    The provider-assigned unique ID for this managed resource.
    ServiceAccountId string
    The service account id.
    id string
    The provider-assigned unique ID for this managed resource.
    service_account_id string
    The service account id.
    id String
    The provider-assigned unique ID for this managed resource.
    serviceAccountId String
    The service account id.
    id string
    The provider-assigned unique ID for this managed resource.
    serviceAccountId string
    The service account id.
    id str
    The provider-assigned unique ID for this managed resource.
    service_account_id str
    The service account id.
    id String
    The provider-assigned unique ID for this managed resource.
    serviceAccountId String
    The service account id.

    Look up Existing ProjectServiceAccount Resource

    Get an existing ProjectServiceAccount 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?: ProjectServiceAccountState, opts?: CustomResourceOptions): ProjectServiceAccount
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            email: Optional[str] = None,
            name: Optional[str] = None,
            project: Optional[str] = None,
            service_account_id: Optional[str] = None,
            skip_wait_for_deletion: Optional[bool] = None,
            timeouts: Optional[ProjectServiceAccountTimeoutsArgs] = None,
            username: Optional[str] = None) -> ProjectServiceAccount
    func GetProjectServiceAccount(ctx *Context, name string, id IDInput, state *ProjectServiceAccountState, opts ...ResourceOption) (*ProjectServiceAccount, error)
    public static ProjectServiceAccount Get(string name, Input<string> id, ProjectServiceAccountState? state, CustomResourceOptions? opts = null)
    public static ProjectServiceAccount get(String name, Output<String> id, ProjectServiceAccountState state, CustomResourceOptions options)
    resources:  _:    type: gitlab:ProjectServiceAccount    get:      id: ${id}
    import {
      to = gitlab_projectserviceaccount.example
      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.
    The following state arguments are supported:
    Email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    Name string
    The name of the user. If not specified, the default Service account user name is used.
    Project string
    The ID or URL-encoded path of the project that the service account is created in.
    ServiceAccountId string
    The service account id.
    SkipWaitForDeletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    Timeouts Pulumi.GitLab.Inputs.ProjectServiceAccountTimeouts
    Username string
    The username of the user. If not specified, it’s automatically generated.
    Email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    Name string
    The name of the user. If not specified, the default Service account user name is used.
    Project string
    The ID or URL-encoded path of the project that the service account is created in.
    ServiceAccountId string
    The service account id.
    SkipWaitForDeletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    Timeouts ProjectServiceAccountTimeoutsArgs
    Username string
    The username of the user. If not specified, it’s automatically generated.
    email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name string
    The name of the user. If not specified, the default Service account user name is used.
    project string
    The ID or URL-encoded path of the project that the service account is created in.
    service_account_id string
    The service account id.
    skip_wait_for_deletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts object
    username string
    The username of the user. If not specified, it’s automatically generated.
    email String
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name String
    The name of the user. If not specified, the default Service account user name is used.
    project String
    The ID or URL-encoded path of the project that the service account is created in.
    serviceAccountId String
    The service account id.
    skipWaitForDeletion Boolean
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts ProjectServiceAccountTimeouts
    username String
    The username of the user. If not specified, it’s automatically generated.
    email string
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name string
    The name of the user. If not specified, the default Service account user name is used.
    project string
    The ID or URL-encoded path of the project that the service account is created in.
    serviceAccountId string
    The service account id.
    skipWaitForDeletion boolean
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts ProjectServiceAccountTimeouts
    username string
    The username of the user. If not specified, it’s automatically generated.
    email str
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name str
    The name of the user. If not specified, the default Service account user name is used.
    project str
    The ID or URL-encoded path of the project that the service account is created in.
    service_account_id str
    The service account id.
    skip_wait_for_deletion bool
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts ProjectServiceAccountTimeoutsArgs
    username str
    The username of the user. If not specified, it’s automatically generated.
    email String
    User account email. If not specified, generates an email prepended with service_account_project_. Custom email addresses require confirmation before the account is active, unless the parent group has a matching verified domain.
    name String
    The name of the user. If not specified, the default Service account user name is used.
    project String
    The ID or URL-encoded path of the project that the service account is created in.
    serviceAccountId String
    The service account id.
    skipWaitForDeletion Boolean
    If set to true, skip waiting for the service account to be fully deleted. This is recommended for gitlab.com where deletion can take a while due to asynchronous processing. Defaults to false.
    timeouts Property Map
    username String
    The username of the user. If not specified, it’s automatically generated.

    Supporting Types

    ProjectServiceAccountTimeouts, ProjectServiceAccountTimeoutsArgs

    Delete string
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.
    Delete string
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.
    delete string
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.
    delete String
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.
    delete string
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.
    delete str
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.
    delete String
    How long to wait for the service account to be fully deleted. Defaults to 10 minutes.

    Import

    Starting in Terraform v1.5.0, you can use an import block to import gitlab.ProjectServiceAccount. For example:

    Importing using the CLI is supported with the following syntax:

    id is in the form of <project_id>:<service_account_id>

    $ pulumi import gitlab:index/projectServiceAccount:ProjectServiceAccount example example
    

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

    Package Details

    Repository
    GitLab pulumi/pulumi-gitlab
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the gitlab Terraform Provider.
    gitlab logo
    Viewing docs for GitLab v10.0.0
    published on Friday, Jun 26, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial