Packer
Yandex
@hashicorp
The Yandex plugin is able to manage images for use with the Yandex Compute Cloud.
- Community
Updated 2 years ago
- GitHub(opens in new tab)
Yandex Import
Type: yandex-import
Artifact BuilderId: packer.post-processor.yandex-import
The Yandex.Cloud Compute Image Import post-processor create new Compute Image from a qcow2 file. As Compute service support image creation from Storage service object just before request to create its upload file into Storage service.
Assigned Service Account must have write permissions to the Yandex Object Storage. A new temporary static access keys from assigned Service Account used to upload file.
Configuration
Required:
Access
token
(string) - OAuth token or IAM token to use to authenticate to Yandex.Cloud. Alternatively you may set value by environment variableYC_TOKEN
.
Common
folder_id
(string) - The folder ID that will be used to launch instances and store images. Alternatively you may set value by environment variableYC_FOLDER_ID
. To use a different folder for looking up the source image or saving the target image to check options 'source_image_folder_id' and 'target_image_folder_id'.
service_account_id
(string) - Service Account ID with proper permission to modify an instance, create and attach disk and make upload to specific Yandex Object Storage paths.
Optional:
Access
endpoint
(string) - Non standard API endpoint. Default isapi.cloud.yandex.net:443
.service_account_key_file
(string) - Contains either a path to or the contents of the Service Account file in JSON format. This can also be specified using environment variableYC_SERVICE_ACCOUNT_KEY_FILE
. You can read how to create service account key file here.max_retries
(int) - The maximum number of times an API request is being executed.
Import
bucket
(string) - The name of the bucket where the qcow2 file will be uploaded to for import. This bucket must exist when the post-processor is run.If import occurred after Yandex-Export post-processor, artifact already in storage service and first paths (URL) is used to, so no need to set this param.
object_name
(string) - The name of the object key inbucket
where the qcow2 file will be copied to import. This is a template engine. Therefore, you may use user variables and template functions in this field.skip_clean
(bool) - Whether skip removing the qcow2 file uploaded to Storage after the import process has completed. Possible values are:true
to leave it in the bucket,false
to remove it. Default isfalse
.
Image
image_name
(string) - The name of the resulting image, which contains 1-63 characters and only supports lowercase English characters, numbers and hyphen. Defaults topacker-{{timestamp}}
.image_description
(string) - The description of the image.image_family
(string) - The family name of the image.image_labels
(map[string]string) - Key/value pair labels to apply to the image.image_min_disk_size_gb
(int) - Minimum size of the disk that will be created from built image, specified in gigabytes. Should be more or equal todisk_size_gb
.image_product_ids
([]string) - License IDs that indicate which licenses are attached to resulting image.image_pooled
(bool) - When true, an image pool will be created for fast creation disks from the image.skip_create_image
(bool) - Skip creating the image. Useful for setting totrue
during a build test stage. Defaults tofalse
.
Basic Example
TBD
{
"variables": {
"token": "{{env `YC_TOKEN`}}"
},
"sensitive-variables": ["token"],
"builders": [
{
"type": "file",
"source": "xenial-server-cloudimg-amd64-disk1.img",
"target": "test_artifact.qcow2"
}
],
"post-processors": [
{
"type": "yandex-import",
"token": "{{user `token`}}",
"folder_id": "b1g8jvfcgmitdrslcn86",
"service_account_id": "ajeui8kdvg8qs44fbrbr",
"bucket": "bucket1",
"image_name": "my-first-imported-image-{{isotime \"02-Jan-06-03-04-05\" | lower }}",
"keep_input_artifact": false
}
]
}