[Yandex Cloud documentation](../../../index.md) > [Yandex Container Registry](../../index.md) > [Step-by-step guides](../index.md) > Managing a registry > Configuring access to a registry

# Configuring access to a registry

You can set up policies for accessing a [registry](../../concepts/registry.md) from specific [IP addresses](../../../vpc/concepts/address.md).

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) the registry was created in.
  1. Navigate to **Container Registry**.
  1. Select the registry to configure access to.
  1. In the left-hand panel, click ![IP-access](../../../_assets/console-icons/shield.svg) **Access for IP address**.
  1. Click **Set**.
  1. Enter the IP address and specify an action: PULL to allow pulling and PUSH to allow pushing [Docker images](../../concepts/docker-image.md) to the registry.
  1. To configure access for multiple IPs, click **Add**.
  1. Click **Save**.

- CLI {#cli}

  1. View the list of available registries, their names and IDs:

     ```bash
     yc container registry list
     ```

     Result:

     ```text
     +----------------------+--------+----------------------+
     |          ID          |  NAME  |      FOLDER ID       |
     +----------------------+--------+----------------------+
     | crpd50616s9a******** | my-reg | b1g88tflru0e******** |
     +----------------------+--------+----------------------+
     ```

  1. Specify registry access settings:

     ```bash
     yc container registry set-ip-permissions <registry_name> \
       --pull <IP_address> \
       --push <IP_address>
     ```

     Where:
     * `--pull`: Flag that allows pulling [Docker images](../../concepts/docker-image.md) from the registry.
     * `--push`: Flag that allows pushing Docker images to the registry.

     To learn more about the command, see the [CLI reference](../../../cli/cli-ref/container/cli-ref/registry/set-ip-permissions.md).

     As a result of executing this command, all the permissions set for IP addresses will be deleted. To continue, type `yes` and press **Enter**.

     Result:

     ```text
     WARN: All current ip permissions will be deleted. Are you sure?[y/N]
     ```

  1. Check the current permissions:

     ```bash
     yc container registry list-ip-permissions <registry_name>
     ```

     Result:

     ```text
     +--------+-----------+
     | ACTION |    IP     |
     +--------+-----------+
     | PULL   | 10.1.2.11 |
     | PUSH   | 10.1.2.11 |
     +--------+-----------+
     ```

- 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 guides 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.

  1. Specify registry access settings in the Terraform configuration file.

     ```hcl
     resource "yandex_container_registry_ip_permission" "my_ip_permission" {
       registry_id = <registry_ID>
       push        = [ "<IP_address>", "<IP_address>" ]
       pull        = [ "<IP_address>", "<IP_address>" ]
     }
     ```

     Where:
     * `my_registry`: Registry ID. If the configuration already contains the [yandex_container_registry](../../../terraform/resources/container_registry.md) resource, you can specify it, e.g., `yandex_container_registry.my_registry.id`.
     * `pull`: IP addresses that can be used to pull [Docker images](../../concepts/docker-image.md) from the registry. This is an optional setting.
     * `push`: IP addresses that can be used to push Docker images to the registry. This is an optional setting.

     For more on the properties of the `yandex_container_registry_ip_permission` resource, see [this provider guide](../../../terraform/resources/container_registry_ip_permission.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 container registry list-ip-permissions <registry_name>
     ```

{% endlist %}