Reserving a static public IP address
You can reserve a public static IP address to use it later to access cloud resources.
Note
Make sure to check out our pricing policy for inactive static public IP addresses.
- In the management console
, navigate to the folder where you want to reserve an IP address. - In the list of services, select Virtual Private Cloud.
- In the left-hand panel, select
IP addresses. - Click Reserve address.
- In the window that opens:
- In the Availability zone field, select the availability zone where you want to reserve the address.
- (Optional) Under Advanced, enable DDoS protection and Deletion protection.
- Click ** Reserve**.
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID>
command. You can also set a different folder for any specific command using the --folder-name
or --folder-id
parameter.
-
See the description of the CLI reserve address command:
yc vpc address create --help
-
Reserve the address by specifying the availability zone:
yc vpc address create --external-ipv4 zone=ru-central1-a
Result:
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
The static public IP address is reserved.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
In the configuration file, define the parameters of the resources you want to create:
-
name
: Static public IP address name. The name format is as follows:- It must be from 2 to 63 characters long.
- 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 isfalse
. -
external_ipv4_address
: IPv4 address description:zone_id
: Availability zone.
Here is an example of the configuration file structure:
resource "yandex_vpc_address" "addr" { name = "<IP_address_name>" deletion_protection = "<deletion_protection>" external_ipv4_address { zone_id = "<availability_zone>" } }
For more information about the
yandex_vpc_address
resource parameters in Terraform, see the provider documentation . -
-
Create resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
Run this command:
terraform plan
You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply
-
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
or this CLI command:yc vpc address list
-
To reserve a static IP address, use the create REST API method for the Address resource or the AddressService/Create 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. Follow these naming requirements:- It must be from 2 to 63 characters long.
- 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 the address will reside in, in the
externalIpv4AddressSpec.zoneId
parameter.