Creating an image from another custom image
To create an image from another custom image:
-
In the management console
, select the folder where you want to create an image. -
Select Compute Cloud.
-
In the left-hand panel, select
Images. -
In the line with the snapshot, click
and select Create image. -
Enter a name for the image. The naming requirements are as follows:
- It must be 2 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Provide a text description for the image, if required.
-
To create an optimized image, enable Optimize for deployment.
-
Click Create.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder through the --folder-name
or --folder-id
parameter.
-
See the description of the CLI command for creating an image:
yc compute image create --help
-
Get a list of images in the default folder:
yc compute image list
Result:
+----------------------+-------------+--------+-------------+--------+ | ID | NAME | FAMILY | PRODUCT IDS | STATUS | +----------------------+-------------+--------+-------------+--------+ | fd8n3spmksqm******** | first-image | | | READY | +----------------------+-------------+--------+-------------+--------+
-
Select
ID
orNAME
of the snapshot you need. -
Create an image in the default folder:
yc compute image create \ --name new-image \ --source-image-name first-image \ --description "new image via yc"
This command will create an image named
new-image
and described asnew image via yc
fromfirst-image
.To create an optimized image, use the
--pooled
flag:yc compute image create \ --name new-image \ --source-image-name first-image \ --description "new image via yc" \ --pooled
If you don't have Terraform, install it and configure the Yandex Cloud provider.
-
Define the parameters of the
yandex_compute_image
resource in the configuration file.Here is an example of the configuration file structure:
resource "yandex_compute_image" "image-1" { name = "<image_name>" source_image = "<source_image_ID>" }
For more information about the resources you can create with Terraform, see the relevant provider documentation
. -
Make sure the configuration files are correct.
-
In the command line, go to the directory where you created the configuration file.
-
Run a check using this command:
terraform plan
If the configuration is correct, the terminal will display a list of resources to create and their parameters. If the configuration contains any errors, Terraform will point them out.
-
-
Deploy the cloud resources.
-
Run this command:
terraform apply
-
Confirm creating the resources.
All the resources you need will then be created in the specified folder. You can check the new resources and their settings using the management console
. -
- Get a list of images using the list REST API method for the Image resource or the ImageService/List gRPC API call.
- Create a new image using the create REST API method for the Image resource or the ImageService/Create gRPC API call. In your request, specify the source image ID.
Once created, the image will get the CREATING
status. Wait until its status changes to READY
before using it.