diff --git a/builder/alicloud/ecs/image_config.go b/builder/alicloud/ecs/image_config.go index 9da9ae996..ef3c5292c 100644 --- a/builder/alicloud/ecs/image_config.go +++ b/builder/alicloud/ecs/image_config.go @@ -12,6 +12,8 @@ import ( "github.com/hashicorp/packer/template/interpolate" ) +// The "AlicloudDiskDevice" object us used for the `ECSSystemDiskMapping` and +// `ECSImagesDiskMappings` options, and contains the following fields: type AlicloudDiskDevice struct { // The value of disk name is blank by default. [2, // 128] English or Chinese characters, must begin with an @@ -19,8 +21,7 @@ type AlicloudDiskDevice struct { // ., _ and -. The disk name will appear on the console. It cannot // begin with `http://` or `https://`. DiskName string `mapstructure:"disk_name" required:"false"` - // Category of the system disk. Optional values - // are: + // Category of the system disk. Optional values are: // - cloud - general cloud disk // - cloud_efficiency - efficiency cloud disk // - cloud_ssd - cloud SSD @@ -32,6 +33,8 @@ type AlicloudDiskDevice struct { // Snapshots are used to create the data // disk After this parameter is specified, Size is ignored. The actual // size of the created disk is the size of the specified snapshot. + // This field is only used in the ECSImagesDiskMappings option, not + // the ECSSystemDiskMapping option. SnapshotId string `mapstructure:"disk_snapshot_id" required:"false"` // The value of disk description is blank by // default. [2, 256] characters. The disk description will appear on the @@ -44,94 +47,51 @@ type AlicloudDiskDevice struct { // such as /dev/xvdb It is null unless the Status is In_use. Device string `mapstructure:"disk_device" required:"false"` // Whether or not to encrypt the data disk. - // If this option is set to true, the data disk will be encryped and corresponding snapshot in the target image will also be encrypted. By + // If this option is set to true, the data disk will be encryped and + // corresponding snapshot in the target image will also be encrypted. By // default, if this is an extra data disk, Packer will not encrypt the // data disk. Otherwise, Packer will keep the encryption setting to what - // it was in the source image. Please refer to Introduction of ECS disk encryption - // for more details. + // it was in the source image. Please refer to Introduction of ECS disk + // encryption for more details. Encrypted config.Trilean `mapstructure:"disk_encrypted" required:"false"` } +// The "AlicloudDiskDevices" object is used to define disk mappings for your +// instance. type AlicloudDiskDevices struct { - // Image disk mapping for system - // disk. - // - `disk_category` (string) - Category of the system disk. Optional values - // are: - // - `cloud` - general cloud disk - // - `cloud_efficiency` - efficiency cloud disk - // - `cloud_ssd` - cloud SSD - // - // For phased-out instance types and non-I/O optimized instances, the - // default value is cloud. Otherwise, the default value is - // cloud\_efficiency. - // - // - `disk_description` (string) - The value of disk description is blank by - // default. \[2, 256\] characters. The disk description will appear on the - // console. It cannot begin with `http://` or `https://`. - // - // - `disk_name` (string) - The value of disk name is blank by default. \[2, - // 128\] English or Chinese characters, must begin with an - // uppercase/lowercase letter or Chinese character. Can contain numbers, - // `.`, `_` and `-`. The disk name will appear on the console. It cannot - // begin with `http://` or `https://`. - // - // - `disk_size` (number) - Size of the system disk, measured in GiB. Value - // range: \[20, 500\]. The specified value must be equal to or greater - // than max{20, ImageSize}. Default value: max{40, ImageSize}. + // Image disk mapping for the system disk. + // See the [disk device configuration](#disk-devices-configuration) section + // for more information on options. + // Usage example: // + // ```json + // "builders": [{ + // "type":"alicloud-ecs", + // "system_disk_mapping": { + // "disk_size": 50, + // "disk_name": "mydisk" + // }, + // ... + // } + // ``` ECSSystemDiskMapping AlicloudDiskDevice `mapstructure:"system_disk_mapping" required:"false"` - // Add one or more data - // disks to the image. - // - // - `disk_category` (string) - Category of the data disk. Optional values - // are: - // - `cloud` - general cloud disk - // - `cloud_efficiency` - efficiency cloud disk - // - `cloud_ssd` - cloud SSD - // - // Default value: cloud. - // - // - `disk_delete_with_instance` (boolean) - Whether or not the disk is - // released along with the instance: - // - True indicates that when the instance is released, this disk will - // be released with it - // - False indicates that when the instance is released, this disk will - // be retained. - // - `disk_description` (string) - The value of disk description is blank by - // default. \[2, 256\] characters. The disk description will appear on the - // console. It cannot begin with `http://` or `https://`. - // - // - `disk_device` (string) - Device information of the related instance: - // such as `/dev/xvdb` It is null unless the Status is In\_use. - // - // - `disk_name` (string) - The value of disk name is blank by default. \[2, - // 128\] English or Chinese characters, must begin with an - // uppercase/lowercase letter or Chinese character. Can contain numbers, - // `.`, `_` and `-`. The disk name will appear on the console. It cannot - // begin with `http://` or `https://`. - // - // - `disk_size` (number) - Size of the data disk, in GB, values range: - // - `cloud` - 5 \~ 2000 - // - `cloud_efficiency` - 20 \~ 2048 - // - `cloud_ssd` - 20 \~ 2048 - // - // The value should be equal to or greater than the size of the specific - // SnapshotId. - // - // - `disk_snapshot_id` (string) - Snapshots are used to create the data - // disk After this parameter is specified, Size is ignored. The actual - // size of the created disk is the size of the specified snapshot. - // - // Snapshots from on or before July 15, 2013 cannot be used to create a - // disk. - // - // - `disk_encrypted` (boolean) - Whether or not to encrypt the data disk. - // If this option is set to true, the data disk will be encryped and corresponding snapshot in the target image will also be encrypted. By - // default, if this is an extra data disk, Packer will not encrypt the - // data disk. Otherwise, Packer will keep the encryption setting to what - // it was in the source image. Please refer to Introduction of [ECS disk encryption](https://www.alibabacloud.com/help/doc-detail/59643.htm) - // for more details. + // Add one or more data disks to the image. + // See the [disk device configuration](#disk-devices-configuration) section + // for more information on options. + // Usage example: // + // ```json + // "builders": [{ + // "type":"alicloud-ecs", + // "image_disk_mappings": [ + // { + // "disk_snapshot_id": "someid", + // "disk_device": "dev/xvdb" + // } + // ], + // ... + // } + // ``` ECSImagesDiskMappings []AlicloudDiskDevice `mapstructure:"image_disk_mappings" required:"false"` } diff --git a/website/pages/docs/builders/alicloud-ecs.mdx b/website/pages/docs/builders/alicloud-ecs.mdx index 5a6306517..ddb8136c6 100644 --- a/website/pages/docs/builders/alicloud-ecs.mdx +++ b/website/pages/docs/builders/alicloud-ecs.mdx @@ -33,8 +33,6 @@ builder. @include 'builder/alicloud/ecs/AlicloudAccessConfig-not-required.mdx' -@include 'builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx' - @include 'builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx' @include 'builder/alicloud/ecs/RunConfig-not-required.mdx' @@ -49,6 +47,9 @@ builder. @include 'helper/communicator/SSH-Agent-Auth-not-required.mdx' +# Disk Devices Configuration: +@include 'builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx' + ## Basic Example Here is a basic example for Alicloud. diff --git a/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx index be66b5d61..9d0a99c0e 100644 --- a/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx +++ b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx @@ -6,8 +6,7 @@ ., _ and -. The disk name will appear on the console. It cannot begin with `http://` or `https://`. -- `disk_category` (string) - Category of the system disk. Optional values - are: +- `disk_category` (string) - Category of the system disk. Optional values are: - cloud - general cloud disk - cloud_efficiency - efficiency cloud disk - cloud_ssd - cloud SSD @@ -19,6 +18,8 @@ - `disk_snapshot_id` (string) - Snapshots are used to create the data disk After this parameter is specified, Size is ignored. The actual size of the created disk is the size of the specified snapshot. + This field is only used in the ECSImagesDiskMappings option, not + the ECSSystemDiskMapping option. - `disk_description` (string) - The value of disk description is blank by default. [2, 256] characters. The disk description will appear on the @@ -31,8 +32,9 @@ such as /dev/xvdb It is null unless the Status is In_use. - `disk_encrypted` (boolean) - Whether or not to encrypt the data disk. - If this option is set to true, the data disk will be encryped and corresponding snapshot in the target image will also be encrypted. By + If this option is set to true, the data disk will be encryped and + corresponding snapshot in the target image will also be encrypted. By default, if this is an extra data disk, Packer will not encrypt the data disk. Otherwise, Packer will keep the encryption setting to what - it was in the source image. Please refer to Introduction of ECS disk encryption - for more details. + it was in the source image. Please refer to Introduction of ECS disk + encryption for more details. diff --git a/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx new file mode 100644 index 000000000..6a724de7b --- /dev/null +++ b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevice.mdx @@ -0,0 +1,4 @@ + + +The "AlicloudDiskDevice" object us used for the `ECSSystemDiskMapping` and +`ECSImagesDiskMappings` options, and contains the following fields: diff --git a/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx index ff556f6b9..01f5c4edb 100644 --- a/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx +++ b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx @@ -1,79 +1,35 @@ -- `system_disk_mapping` (AlicloudDiskDevice) - Image disk mapping for system - disk. - - `disk_category` (string) - Category of the system disk. Optional values - are: - - `cloud` - general cloud disk - - `cloud_efficiency` - efficiency cloud disk - - `cloud_ssd` - cloud SSD +- `system_disk_mapping` (AlicloudDiskDevice) - Image disk mapping for the system disk. + See the [disk device configuration](#disk-devices-configuration) section + for more information on options. + Usage example: - For phased-out instance types and non-I/O optimized instances, the - default value is cloud. Otherwise, the default value is - cloud\_efficiency. - - - `disk_description` (string) - The value of disk description is blank by - default. \[2, 256\] characters. The disk description will appear on the - console. It cannot begin with `http://` or `https://`. - - - `disk_name` (string) - The value of disk name is blank by default. \[2, - 128\] English or Chinese characters, must begin with an - uppercase/lowercase letter or Chinese character. Can contain numbers, - `.`, `_` and `-`. The disk name will appear on the console. It cannot - begin with `http://` or `https://`. - - - `disk_size` (number) - Size of the system disk, measured in GiB. Value - range: \[20, 500\]. The specified value must be equal to or greater - than max{20, ImageSize}. Default value: max{40, ImageSize}. + ```json + "builders": [{ + "type":"alicloud-ecs", + "system_disk_mapping": { + "disk_size": 50, + "disk_name": "mydisk" + }, + ... + } + ``` -- `image_disk_mappings` ([]AlicloudDiskDevice) - Add one or more data - disks to the image. +- `image_disk_mappings` ([]AlicloudDiskDevice) - Add one or more data disks to the image. + See the [disk device configuration](#disk-devices-configuration) section + for more information on options. + Usage example: - - `disk_category` (string) - Category of the data disk. Optional values - are: - - `cloud` - general cloud disk - - `cloud_efficiency` - efficiency cloud disk - - `cloud_ssd` - cloud SSD - - Default value: cloud. - - - `disk_delete_with_instance` (boolean) - Whether or not the disk is - released along with the instance: - - True indicates that when the instance is released, this disk will - be released with it - - False indicates that when the instance is released, this disk will - be retained. - - `disk_description` (string) - The value of disk description is blank by - default. \[2, 256\] characters. The disk description will appear on the - console. It cannot begin with `http://` or `https://`. - - - `disk_device` (string) - Device information of the related instance: - such as `/dev/xvdb` It is null unless the Status is In\_use. - - - `disk_name` (string) - The value of disk name is blank by default. \[2, - 128\] English or Chinese characters, must begin with an - uppercase/lowercase letter or Chinese character. Can contain numbers, - `.`, `_` and `-`. The disk name will appear on the console. It cannot - begin with `http://` or `https://`. - - - `disk_size` (number) - Size of the data disk, in GB, values range: - - `cloud` - 5 \~ 2000 - - `cloud_efficiency` - 20 \~ 2048 - - `cloud_ssd` - 20 \~ 2048 - - The value should be equal to or greater than the size of the specific - SnapshotId. - - - `disk_snapshot_id` (string) - Snapshots are used to create the data - disk After this parameter is specified, Size is ignored. The actual - size of the created disk is the size of the specified snapshot. - - Snapshots from on or before July 15, 2013 cannot be used to create a - disk. - - - `disk_encrypted` (boolean) - Whether or not to encrypt the data disk. - If this option is set to true, the data disk will be encryped and corresponding snapshot in the target image will also be encrypted. By - default, if this is an extra data disk, Packer will not encrypt the - data disk. Otherwise, Packer will keep the encryption setting to what - it was in the source image. Please refer to Introduction of [ECS disk encryption](https://www.alibabacloud.com/help/doc-detail/59643.htm) - for more details. + ```json + "builders": [{ + "type":"alicloud-ecs", + "image_disk_mappings": [ + { + "disk_snapshot_id": "someid", + "disk_device": "dev/xvdb" + } + ], + ... + } + ``` diff --git a/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx new file mode 100644 index 000000000..d7656e239 --- /dev/null +++ b/website/pages/partials/builder/alicloud/ecs/AlicloudDiskDevices.mdx @@ -0,0 +1,4 @@ + + +The "AlicloudDiskDevices" object is used to define disk mappings for your +instance.