Getting information about a public image
You can get a public image ID or other information about it.
Getting a public image ID
- In the management console
, go to the folder you want to create a virtual machine in. - Select Compute Cloud.
- At the top right, click Create resource.
- In the list that opens, select Virtual machine instance.
- Under Boot disk image, click
next to the public image you need. - Under Product IDs, you will see the public image ID: image_id.
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.
-
View the description of the CLI command to get information about a public image of a disk:
yc compute image get --help
-
Get the public image ID by specifying the operating system family name:
yc compute image get-latest-from-family <family_name> --folder-id standard-images
To learn the image family name, get a list of images in the folder.
Result:
id: fd85u0rct32prepgjlv0 folder_id: standard-images created_at: "2024-03-11T10:57:40Z" name: ubuntu-22-04-lts-v20240311 description: ubuntu 22.04 lts family: ubuntu-2204-lts storage_size: "7633633280" min_disk_size: "8589934592" product_ids: - f2ef01lju2nsansfdahf status: READY os: type: LINUX pooled: true
You will find the public image ID in the
id
row.
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.
To get a public image ID using Terraform:
-
Add the
data
andoutput
sections to the Terraform configuration file:data "yandex_compute_image" "ubuntu_image" { family = "<family_name>" } output "ubuntu_id" { value = data.yandex_compute_image.my_image.image_id }
Where:
data "yandex_compute_image"
: Description of the public image as a data source:output "image"
: Output variable containing the public image ID:value
: Returned value.
For more information about the
yandex_compute_image
data source parameters, 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.
Terraform will create the required resources and display the output variable values in the terminal. To check the results, run:
terraform output
Result:
image = "fd85u0rct32prepgjlv0"
-
To get a public image ID, use the get REST API method for the Image resource or the ImageService/Get gRPC API call.
Getting information about a public image
- In the management console
, go to the folder you want to create a virtual machine in. - Select Compute Cloud.
- At the top right, click Create resource.
- In the list that opens, select Virtual machine instance.
- Under Boot disk image, click
next to the public image you need. - The window that opens will display information about the public image.
- To view all available public images, go to the Marketplace tab and click Show all Marketplace products.
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.
-
View the description of the CLI command to get information about a public image:
yc compute image get --help
-
Get information about a public image by specifying its ID:
yc compute image get <image_ID>
To find out the image ID, get a list of images in the folder.
Result:
id: fd89ls0nj4oqmlhhi568 folder_id: standard-images created_at: "2024-04-29T10:58:27Z" name: ubuntu-2204-lts-oslogin-v20240429 description: Ubuntu 22.04 OsLogin family: ubuntu-2204-lts-oslogin storage_size: "7511998464" min_disk_size: "10737418240" product_ids: - f2e48vn7nr04r2bpg4eg status: READY os: type: LINUX pooled: true
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.
To get information about a public image using Terraform:
-
Add the
data
andoutput
sections to the Terraform configuration file:data "yandex_compute_image" "my_image" { image_id = "<image_ID>" } output "image" { value = data.yandex_compute_image.my_image.family }
Where:
data "yandex_compute_image"
: Description of the public image as a data source:image_id
: Public image ID. To find out the image ID, get a list of images in the folder.
output "image"
: Output variable containing information about the OS family:value
: Returned value.
You can replace
family
with any other parameter to get the information you need. For more information about theyandex_compute_image
data source parameters, see the relevant 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.
Terraform will create the required resources and display the output variable values in the terminal. To check the results, run:
terraform output
Result:
image = "ubuntu-2204-lts"
-
To get detailed information about a public disk image, use the get REST API method for the Image resource or the ImageService/Get gRPC API call.
You can also view information about all available public images in Cloud Marketplace.