GroupServiceAccount

class GroupServiceAccount : KotlinCustomResource

The gitlab.GroupServiceAccount resource allows creating a GitLab group service account. Upstream API: GitLab REST API docs

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gitlab from "@pulumi/gitlab";
// This must be a top-level group
const example = new gitlab.Group("example", {
name: "example",
path: "example",
description: "An example group",
});
// The service account against the top-level group
const exampleSa = new gitlab.GroupServiceAccount("example_sa", {
group: example.id,
name: "example-name",
username: "example-username",
});
// Group to assign the service account to. Can be the same top-level group resource as above, or a subgroup of that group.
const exampleSubgroup = new gitlab.Group("example_subgroup", {
name: "subgroup",
path: "example/subgroup",
description: "An example subgroup",
});
// To assign the service account to a group
const exampleMembership = new gitlab.GroupMembership("example_membership", {
groupId: exampleSubgroup.id,
userId: exampleSa.serviceAccountId,
accessLevel: "developer",
expiresAt: "2020-03-14",
});
import pulumi
import pulumi_gitlab as gitlab
# This must be a top-level group
example = gitlab.Group("example",
name="example",
path="example",
description="An example group")
# The service account against the top-level group
example_sa = gitlab.GroupServiceAccount("example_sa",
group=example.id,
name="example-name",
username="example-username")
# Group to assign the service account to. Can be the same top-level group resource as above, or a subgroup of that group.
example_subgroup = gitlab.Group("example_subgroup",
name="subgroup",
path="example/subgroup",
description="An example subgroup")
# To assign the service account to a group
example_membership = gitlab.GroupMembership("example_membership",
group_id=example_subgroup.id,
user_id=example_sa.service_account_id,
access_level="developer",
expires_at="2020-03-14")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using GitLab = Pulumi.GitLab;
return await Deployment.RunAsync(() =>
{
// This must be a top-level group
var example = new GitLab.Group("example", new()
{
Name = "example",
Path = "example",
Description = "An example group",
});
// The service account against the top-level group
var exampleSa = new GitLab.GroupServiceAccount("example_sa", new()
{
Group = example.Id,
Name = "example-name",
Username = "example-username",
});
// Group to assign the service account to. Can be the same top-level group resource as above, or a subgroup of that group.
var exampleSubgroup = new GitLab.Group("example_subgroup", new()
{
Name = "subgroup",
Path = "example/subgroup",
Description = "An example subgroup",
});
// To assign the service account to a group
var exampleMembership = new GitLab.GroupMembership("example_membership", new()
{
GroupId = exampleSubgroup.Id,
UserId = exampleSa.ServiceAccountId,
AccessLevel = "developer",
ExpiresAt = "2020-03-14",
});
});
package main
import (
"github.com/pulumi/pulumi-gitlab/sdk/v8/go/gitlab"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// This must be a top-level group
example, err := gitlab.NewGroup(ctx, "example", &gitlab.GroupArgs{
Name: pulumi.String("example"),
Path: pulumi.String("example"),
Description: pulumi.String("An example group"),
})
if err != nil {
return err
}
// The service account against the top-level group
exampleSa, err := gitlab.NewGroupServiceAccount(ctx, "example_sa", &gitlab.GroupServiceAccountArgs{
Group: example.ID(),
Name: pulumi.String("example-name"),
Username: pulumi.String("example-username"),
})
if err != nil {
return err
}
// Group to assign the service account to. Can be the same top-level group resource as above, or a subgroup of that group.
exampleSubgroup, err := gitlab.NewGroup(ctx, "example_subgroup", &gitlab.GroupArgs{
Name: pulumi.String("subgroup"),
Path: pulumi.String("example/subgroup"),
Description: pulumi.String("An example subgroup"),
})
if err != nil {
return err
}
// To assign the service account to a group
_, err = gitlab.NewGroupMembership(ctx, "example_membership", &gitlab.GroupMembershipArgs{
GroupId: exampleSubgroup.ID(),
UserId: exampleSa.ServiceAccountId,
AccessLevel: pulumi.String("developer"),
ExpiresAt: pulumi.String("2020-03-14"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gitlab.Group;
import com.pulumi.gitlab.GroupArgs;
import com.pulumi.gitlab.GroupServiceAccount;
import com.pulumi.gitlab.GroupServiceAccountArgs;
import com.pulumi.gitlab.GroupMembership;
import com.pulumi.gitlab.GroupMembershipArgs;
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) {
// This must be a top-level group
var example = new Group("example", GroupArgs.builder()
.name("example")
.path("example")
.description("An example group")
.build());
// The service account against the top-level group
var exampleSa = new GroupServiceAccount("exampleSa", GroupServiceAccountArgs.builder()
.group(example.id())
.name("example-name")
.username("example-username")
.build());
// Group to assign the service account to. Can be the same top-level group resource as above, or a subgroup of that group.
var exampleSubgroup = new Group("exampleSubgroup", GroupArgs.builder()
.name("subgroup")
.path("example/subgroup")
.description("An example subgroup")
.build());
// To assign the service account to a group
var exampleMembership = new GroupMembership("exampleMembership", GroupMembershipArgs.builder()
.groupId(exampleSubgroup.id())
.userId(exampleSa.serviceAccountId())
.accessLevel("developer")
.expiresAt("2020-03-14")
.build());
}
}
resources:
# This must be a top-level group
example:
type: gitlab:Group
properties:
name: example
path: example
description: An example group
# The service account against the top-level group
exampleSa:
type: gitlab:GroupServiceAccount
name: example_sa
properties:
group: ${example.id}
name: example-name
username: example-username
# Group to assign the service account to. Can be the same top-level group resource as above, or a subgroup of that group.
exampleSubgroup:
type: gitlab:Group
name: example_subgroup
properties:
name: subgroup
path: example/subgroup
description: An example subgroup
# To assign the service account to a group
exampleMembership:
type: gitlab:GroupMembership
name: example_membership
properties:
groupId: ${exampleSubgroup.id}
userId: ${exampleSa.serviceAccountId}
accessLevel: developer
expiresAt: 2020-03-14

Import

Starting in Terraform v1.5.0 you can use an import block to import gitlab_group_service_account. For example: terraform import { to = gitlab_group_service_account.example id = "see CLI command below for ID" } Import using the CLI is supported using the following syntax:

$ pulumi import gitlab:index/groupServiceAccount:GroupServiceAccount You can import a group service account using `<resource> <id>`. The

id is in the form of :

$ pulumi import gitlab:index/groupServiceAccount:GroupServiceAccount example example

Properties

Link copied to clipboard
val group: Output<String>

The ID or URL-encoded path of the group that the service account is created in. Must be a top level group.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val name: Output<String>

The name of the user. If not specified, the default Service account user name is used.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The service account id.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val username: Output<String>?

The username of the user. If not specified, it’s automatically generated.