[Yandex Cloud documentation](../../../index.md) > [Yandex Managed Service for GitLab](../../index.md) > [Step-by-step guides](../index.md) > Creating and activating an instance

# Creating and activating a Yandex Managed Service for GitLab instance

## Creating a Managed Service for GitLab instance {#create}

To create a Managed Service for GitLab instance, you need the [vpc.user](../../../vpc/security/index.md#vpc-user) role and the [gitlab.editor role or higher](../../security/index.md#roles-list). For more information on assigning roles, see [this Identity and Access Management guide](../../../iam/operations/roles/grant.md).

{% note warning %}

Once you have created an instance, you cannot change its network configuration, i.e., availability zone and subnet.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the management console, select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) where you want to create a [GitLab instance](../../concepts/index.md#instance).
  1. Navigate to **Managed Service for&nbsp;GitLab**.
  1. Click **Create instance**.
  1. At the top of the page:
  
     1. Enter a name for your instance. It must be unique within Yandex Cloud.
  
        * Length: between 3 and 63 characters.
        * It can only contain lowercase Latin letters, numbers, and hyphens.
        * It must start with a letter and cannot end with a hyphen.
  
     1. Optionally, enter a description for the instance.
     1. Optionally, add [labels](../../../resource-manager/concepts/labels.md) to break instances into logical groups.
     1. Optionally, set instance protection against accidental deletion by users.
  
  1. Under **Configuration**:
  
     1. Select the [instance type](../../concepts/index.md#config). After you create an instance, you can [upgrade its type](instance-update.md) to a higher performing one.
     1. Specify the [availability zone](../../../overview/concepts/geo-scope.md). After you create an instance, you cannot change its availability zone.
     1. Specify the [subnet](../../../vpc/concepts/network.md#subnet) to host the instance. Currently, Yandex Cloud technical restrictions do not allow selecting a subnet with the `192.168.0.0/24` address range.
     1. Select a [security group](../../../vpc/concepts/security-groups.md) or create a new one:
  
        1. Click **Create group**.
        1. Enter a name and description for the security group. You can add rules for the security group later in **Virtual Private Cloud**.
        1. Click **Create**.
  
        If you do not specify a separate security group, the [default security group](../../../vpc/concepts/security-groups.md#default-security-group) created in the instance network will apply.
        
        [Configure](../configure-security-group.md) your security group so that its rules allow incoming and outgoing traffic on the specified ports and IP addresses.
              
        {% note warning %}
        
        The security group's setup determines the Managed Service for GitLab instance performance and availability.
        
        {% endnote %}
        
        If you have issues with setting up a security group, contact [support](https://center.yandex.cloud/support).
  
     1. Select the [disk](../../../compute/concepts/disk.md) size. After you create an instance, [you can increase](instance-update.md) its disk size.
     1. Specify the [instance domain name](../../../compute/concepts/network.md#hostname): the system will automatically create the relevant DNS records for it in the `.gitlab.yandexcloud.net` domain.
  
        The domain name must be unique within Yandex Cloud.
        
        * It must be from 5 to 50 characters long.
        * It can include lowercase Latin letters, numbers, and hyphens.
        * It cannot not start or end with a hyphen.
  
     1. Set up the automatic backup retention period in days.
     1. Optionally, enable [approval rules](../../concepts/approval-rules.md). To do this, select the appropriate configuration for approval rules.
  
        {% note warning %}
        
        In Managed Service for GitLab, you pay for approval rules depending on your [configuration](../../concepts/approval-rules.md#packages). For more information, see [Yandex Managed Service for GitLab pricing policy](../../pricing.md).
        
        {% endnote %}
  
  1. Under **Administrator data**, specify:
     * **Email**: Email address of the GitLab instance administrator. This is the address to receive the email with a link to create a password.
     * **Login**: Administrator login.
  1. Optionally, under **Advanced settings**, enable deletion of untagged images. This setting affects the amount of free disk space on the instance.
  1. Click **Create**.
  1. Wait until the instance is ready: its status on the Managed Service for GitLab dashboard will change to **Running**. This may take a while.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).
  
  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
  
  1. See the description of the [CLI](../../../cli/index.md) command for creating a Managed Service for GitLab instance:
  
       ```bash
       yc managed-gitlab instance create --help
       ```
  
  1. Select a [subnet](../../../vpc/concepts/network.md#subnet):
  
      ```bash
      yc vpc subnet list
      ```
  
      Result:
  
       ```text
       +----------------------+---------------------------+----------------------+----------------+-------------------+-----------------+
       |          ID          |           NAME            |      NETWORK ID      | ROUTE TABLE ID |       ZONE        |      RANGE      |
       +----------------------+---------------------------+----------------------+----------------+-------------------+-----------------+
       | e9bnlm18l70a******** |   default-ru-central1-a   | enpe3m3fa00u******** |                |   ru-central1-a   | [10.128.0.0/24] |
       +----------------------+---------------------------+----------------------+----------------+-------------------+-----------------+
       ```
  
  1. Create a GitLab instance (this example does not use all available parameters):
  
      ```bash
      yc managed-gitlab instance create \
        --name first-instance \
        --resource-preset-id <host_class> \
        --disk-size <disk_size_in_GB> \
        --admin-login <admin_login> \
        --admin-email <admin_email_address> \
        --domain-prefix <instance_domain_name> \
        --deletion-protection \
        --approval-rules <approval_rule_configuration> \
        --subnet-id <subnet_ID>
      ```
  
      Where:
      * `--name`: Instance name, unique within Yandex Cloud. Follow these naming requirements:
  
        * Length: between 3 and 63 characters.
        * It can only contain lowercase Latin letters, numbers, and hyphens.
        * It must start with a letter and cannot end with a hyphen.
  
      * `--resource-preset-id`: Host class. It determines the configuration of the VM to host the GitLab instance. The possible values are:
        * `s2.micro`: 2 vCPUs, 8 GB RAM
        * `s2.small`: 4 vCPUs, 16 GB RAM
        * `s2.medium`: 8 vCPUs, 32 GB RAM
        * `s2.large`: 16 vCPUs, 64 GB RAM
      * `--disk-size`: Disk size, in GB.
      * `--admin-login`: GitLab instance admin login.
      * `--admin-email`: Instance admin email address. This is the address to receive the email with a link to create a password.
      * `--domain-prefix`: [Instance domain name](../../../compute/concepts/network.md#hostname). The system will automatically create the relevant DNS records for it in the `.gitlab.yandexcloud.net` domain.
  
        The domain name must be unique within Yandex Cloud.
        
        * It must be from 5 to 50 characters long.
        * It can include lowercase Latin letters, numbers, and hyphens.
        * It cannot not start or end with a hyphen.
  
      * `--deletion-protection`: Instance protection against accidental deletion by users.
      * `--approval-rules`: [Approval rule](../../concepts/approval-rules.md) configuration. The possible values are:
        * `BASIC`
        * `STANDARD`
        * `ADVANCED`
  
        {% note warning %}
        
        In Managed Service for GitLab, you pay for approval rules depending on your [configuration](../../concepts/approval-rules.md#packages). For more information, see [Yandex Managed Service for GitLab pricing policy](../../pricing.md).
        
        {% endnote %}
  
      * `--subnet-id`: ID of the selected subnet.
  
      Result:
  
      ```text
      id: c17c60tpadua********
      folder_id: b1g2slt7p9ug********
      created_at: "2025-07-20T18:34:16.078Z"
      updated_at: "2025-07-20T18:34:16.078Z"
      name: test-cli
      resource_preset_id: s2.small
      disk_size: "107374182400"
      status: RUNNING
      admin_login: admin-gl
      admin_email: user@example.com
      domain: test-domain-user.gitlab.yandexcloud.net
      subnet_id: e9b4rrpuu2a********
      backup_retain_period_days: "7"
      deletion_protection: true
      approval_rules_id: BASIC
      gitlab_version: 17.11.6
      ```
  
      For more information about this command, see the [CLI reference](../../cli-ref/instance/create.md).

- Terraform {#tf}

  With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
  
  Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
  
  For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../../terraform/index.md).

  If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
  
  
  To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../../terraform/authentication.md) using the appropriate method.

  To create a GitLab instance:

  1. In the Terraform configuration file, describe the resources you want to create:

     ```hcl
     resource "yandex_gitlab_instance" "my_gitlab_instance" {
       name                      = "<instance_name>"
       resource_preset_id        = "<host_class>"
       disk_size                 = <disk_size_in_GB>
       admin_login               = "<admin_login>"
       admin_email               = "<admin_email_address>"
       domain                    = "<instance_domain_name>"
       subnet_id                 = "<subnet_ID>"
       approval_rules_id         = "<approval_rule_configuration>"
       backup_retain_period_days = <backup_retention_period>
       deletion_protection       = <true_or_false>
     }
     ```

     Where:
     * `name`: Instance name, unique within Yandex Cloud. The naming requirements are as follows:

        * Length: between 3 and 63 characters.
        * It can only contain lowercase Latin letters, numbers, and hyphens.
        * It must start with a letter and cannot end with a hyphen.

     * `resource_preset_id`: Host class. It determines the configuration of the VM to host the GitLab instance. The possible values are:
        * `s2.micro`: 2 vCPUs, 8 GB RAM
        * `s2.small`: 4 vCPUs, 16 GB RAM
        * `s2.medium`: 8 vCPUs, 32 GB RAM
        * `s2.large`: 16 vCPUs, 64 GB RAM
     * `disk_size`: Disk size, in GB.
     * `admin_login`: GitLab instance admin login.
     * `admin_email`: Instance admin email address. This is the address to receive the email with a link to create a password.
     * `domain`: [Instance domain name](../../../compute/concepts/network.md#hostname) in `<name>.gitlab.yandexcloud.net` format. The system will automatically create the relevant DNS records for it in the `.gitlab.yandexcloud.net` domain.

        The domain name must be unique within Yandex Cloud.
        
        * It must be from 5 to 50 characters long.
        * It can include lowercase Latin letters, numbers, and hyphens.
        * It cannot not start or end with a hyphen.

     * `subnet_id`: ID of the selected subnet.
     * `approval_rules_id`: [Approval rule](../../concepts/approval-rules.md) configuration. The possible values are:
        * `BASIC`
        * `STANDARD`
        * `ADVANCED`

        {% note warning %}
        
        In Managed Service for GitLab, you pay for approval rules depending on your [configuration](../../concepts/approval-rules.md#packages). For more information, see [Yandex Managed Service for GitLab pricing policy](../../pricing.md).
        
        {% endnote %}

     * `backup_retain_period_days`: Automatic backup retention period, in days.
     * `deletion_protection`: Instance protection against accidental deletion by users. The possible values are `true` or `false`.

     For more information about `yandex_gitlab_instance` properties, see [this provider guide](../../../terraform/resources/gitlab_instance.md).

  1. Create the resources:

     1. In the terminal, navigate to the configuration file directory.
     1. Make sure the configuration is correct using this command:
     
        ```bash
        terraform validate
        ```
     
        If the configuration is valid, you will get this message:
     
        ```bash
        Success! The configuration is valid.
        ```
     
     1. Run this command:
     
        ```bash
        terraform plan
        ```
     
        You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
     1. Apply the configuration changes:
     
        ```bash
        terraform apply
        ```
     
     1. Type `yes` and press **Enter** to confirm the changes.

     Terraform will create all the required resources. You can check the new resources in the [management console](https://console.yandex.cloud) or using this [CLI](../../../cli/index.md) command:

     ```bash
     yc managed-gitlab instance list
     ```

- API {#api}

  Use the [Create](../../api-ref/Instance/create.md) REST API method for the [Instance](../../api-ref/Instance/index.md) resource or the [InstanceService/Create](../../api-ref/grpc/Instance/create.md) gRPC API call.

{% endlist %}

{% note info %}

When you create an instance in Managed Service for GitLab, the system automatically generates an SSL certificate. Using HTTPS requires no advanced setup.

{% endnote %}

## Activating a Managed Service for GitLab instance {#activate}

After the instance status changes to **Running**, activate the instance:

1. Follow the link you received in your administrator mailbox after creating the instance.

   If you cannot access the GitLab web UI via the link, create a separate security group and [configure it](../configure-security-group.md) so that its rules allow incoming traffic from the required ports and IP addresses.

1. Change the administrator password.
1. Log in using the administrator username and password.

Further on, to open the GitLab web UI, [get detailed information about your instance](instance-list.md#get) and follow the link in the **Domain** field.