Reserving a static public IP address
You can reserve a static public IP address to use later for accessing cloud resources.
Note
Make sure to check out our pricing policy for inactive static public IPs.
- In the management console
, go to the page of 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 command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder 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.
Terraform
For more information about the provider resources, see the documentation on the Terraform
If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the parameters of the resources you want to create:
-
name
: Static public IP address name. The name format is as follows:- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
deletion_protection
: Static public IP deletion protection. 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, change to the folder where you edited the configuration file.
-
Make sure the configuration file is correct using the command:
terraform validate
If the configuration is correct, the following message is returned:
Success! The configuration is valid.
-
Run the command:
terraform plan
The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
in the terminal and press Enter.
All the resources you need will then be created 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. The name format is as follows:- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
ID of the availability zone the address will reside in, in the
externalIpv4AddressSpec.zoneId
parameter.