[Yandex Cloud documentation](../../index.md) > [Yandex Virtual Private Cloud](../index.md) > [Step-by-step guides](index.md) > IP address > Reserving a static public IP address

# Reserving a static public IP address


You can reserve a public [static IP address](../concepts/address.md#public-addresses) to use it later to access cloud resources.

{% note info %}

Make sure to check out our [pricing policy](../pricing.md#prices-public-ip) for inactive static public IP addresses.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

   1. In the [management console](https://console.yandex.cloud), select the folder where you want to reserve an address.
   1. Navigate to **Virtual Private Cloud**.
   1. In the left-hand panel, select ![image](../../_assets/console-icons/map-pin.svg) **Public IP addresses**.
   1. Click **Reserve public IP address**.
   1. In the window that opens:
       * In the **Availability zone** field, select the availability zone where you want to reserve the address.
       * Optionally, under **Advanced**, enable **DDoS protection** and **Deletion protection**.
       * Optionally, specify labels.
       * Optionally, to add a DNS record, expand the **DNS settings** list and click **Add record**. In the section that opens, do the following:
           * Select a DNS zone.
           * Specify an FQDN. You can create a new domain or use a domain whose name matches the DNS zone name.
           * In the **TTL** field, specify the record lifetime in seconds.
   1. Click ** Reserve**.

- 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 command for reserving an address:

      ```bash
      yc vpc address create --help
      ```

   1. Reserve the address by specifying the availability zone:

      ```bash
      yc vpc address create --external-ipv4 zone=ru-central1-a --deletion-protection
      ```

      Where:

      * `--external-ipv4`: IPv4 address description:
        * `zone`: [Availability zone](../../overview/concepts/geo-scope.md).
      * `--deletion-protection`: Enables protection of a static public IP address against deletion. You cannot delete an IP address with this option enabled.

      Result:

      ```text
      id: e9b6un9gkso6********
      folder_id: b1g7gvsi89m3********
      created_at: "2021-01-19T17:52:42Z"
      external_ipv4_address:
        address: 178.154.253.52
        zone_id: ru-central1-a
        requirements: {}
      reserved: true
      type: EXTERNAL
      ip_version: IPV4
      deletion_protection: true
      ```

      The static public IP address is reserved.

- 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. In the configuration file, describe the resources you want to create:

     * `name`: Static public IP address name. The name format is 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.

     * `deletion_protection`: Protection of your static public IP address against deletion. You cannot delete an IP address with this option enabled. The default value is `false`.
     * `external_ipv4_address`: IPv4 address description:
        * `zone_id`: [Availability zone](../../overview/concepts/geo-scope.md).

     Here is an example of the configuration file structure:

     ```hcl
     resource "yandex_vpc_address" "addr" {
       name = "<IP_address_name>"
       deletion_protection = "<protect_address_from_deletion>"
       external_ipv4_address {
         zone_id = "<availability_zone>"
       }
     }
     ```

     For more information about the `yandex_vpc_address` resource parameters in Terraform, see the [provider documentation](../../terraform/resources/vpc_address.md).

  1. Create 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.

     This will create all the resources you need in the specified folder. You can check the new resources and their configuration using the [management console](https://console.yandex.cloud) or this [CLI](../../cli/quickstart.md) command:

     ```bash
     yc vpc address list
     ```

- API {#api}

  To reserve a static IP address, use the [create](../api-ref/Address/create.md) REST API method for the [Address](../api-ref/Address/index.md) resource or the [AddressService/Create](../api-ref/grpc/Address/create.md) gRPC API call, and provide the following in the request:

    * ID of the folder the static IP address will reside in, in the `folderId` parameter.
    * Name of the static public IP address, in the `name` parameter. The name format is 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.

    * ID of the [availability zone](../../overview/concepts/geo-scope.md) the address will reside in, in the `externalIpv4AddressSpec.zoneId` parameter.

  To protect a static public IP address against deletion, provide `deletionProtection` set to `true` in the request.

{% endlist %}