github.com/StackPointCloud/packer@v0.10.2-0.20180716202532-b28098e0f79b/website/source/docs/builders/alicloud-ecs.html.md (about)

     1  ---
     2  description: |
     3      The `alicloud-ecs` Packer builder plugin provide the capability to build
     4      customized images based on an existing base images.
     5  layout: docs
     6  page_title: Alicloud Image Builder
     7  sidebar_current: 'docs-builders-alicloud-ecs'
     8  ---
     9  
    10  # Alicloud Image Builder
    11  
    12  Type: `alicloud-ecs`
    13  
    14  The `alicloud-ecs` Packer builder plugin provide the capability to build
    15  customized images based on an existing base images.
    16  
    17  ## Configuration Reference
    18  
    19  The following configuration options are available for building Alicloud images.
    20  In addition to the options listed here,
    21  a [communicator](/docs/templates/communicator.html) can be configured for this
    22  builder.
    23  
    24  ### Required:
    25  
    26  -   `access_key` (string) - This is the Alicloud access key. It must be provided,
    27      but it can also be sourced from the `ALICLOUD_ACCESS_KEY` environment
    28      variable.
    29  
    30  -   `image_name` (string) - The name of the user-defined image, \[2, 128\] English
    31      or Chinese characters. It must begin with an uppercase/lowercase letter or
    32      a Chinese character, and may contain numbers, `_` or `-`. It cannot begin with
    33      `http://` or `https://`.
    34  
    35  -   `instance_type` (string) - Type of the instance. For values, see [Instance
    36      Type Table](https://www.alibabacloud.com/help/doc-detail/25378.htm?spm=a3c0i.o25499en.a3.9.14a36ac8iYqKRA).
    37      You can also obtain the latest instance type table by invoking the [Querying
    38      Instance Type Table](https://intl.aliyun.com/help/doc-detail/25620.htm?spm=a3c0i.o25499en.a3.6.Dr1bik)
    39      interface.
    40  
    41  -   `region` (string) - This is the Alicloud region. It must be provided, but it
    42      can also be sourced from the `ALICLOUD_REGION` environment variables.
    43  
    44  -   `secret_key` (string) - This is the Alicloud secret key. It must be provided,
    45      but it can also be sourced from the `ALICLOUD_SECRET_KEY` environment
    46      variable.
    47  
    48  -   `source_image` (string) - This is the base image id which you want to create
    49      your customized images.
    50  
    51  ### Optional:
    52  
    53  -   `force_stop_instance` (boolean) - Whether to force shutdown upon device restart.
    54      The default value is `false`.
    55  
    56      If it is set to `false`, the system is shut down normally; if it is set to
    57      `true`, the system is forced to shut down.
    58  
    59  -   `image_copy_names` (array of string) - The name of the destination image, \[2,
    60      128\] English or Chinese characters. It must begin with an uppercase/lowercase
    61      letter or a Chinese character, and may contain numbers, `_` or `-`. It cannot
    62      begin with `http://` or `https://`.
    63  
    64  -   `image_copy_regions` (array of string) - Copy to the destination regionIds.
    65  
    66  -   `image_description` (string) - The description of the image, with a length
    67      limit of 0 to 256 characters. Leaving it blank means null, which is the
    68      default value. It cannot begin with `http://` or `https://`.
    69  
    70  -   `image_disk_mappings` (array of image disk mappings) - Add one or more data disks
    71      to the image.
    72  
    73      -   `disk_category` (string) - Category of the data disk. Optional values are:
    74          -   cloud - general cloud disk
    75          -   cloud\_efficiency - efficiency cloud disk
    76          -   cloud\_ssd - cloud SSD
    77  
    78          Default value: cloud.
    79  
    80      -   `disk_delete_with_instance` (boolean) - Whether or not the disk is released along with the instance:
    81          -   True indicates that when the instance is released, this disk will be released with it
    82          -   False indicates that when the instance is released, this disk will be retained.
    83  
    84      -   `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://`.
    85  
    86      -   `disk_device` (string) - Device information of the related instance: such as
    87          `/dev/xvdb` It is null unless the Status is In\_use.
    88  
    89      -   `disk_name` (string) - The value of disk name is blank by default. \[2, 128\]
    90          English or Chinese characters, must begin with an uppercase/lowercase letter
    91          or Chinese character. Can contain numbers, `.`, `_` and `-`. The disk name
    92          will appear on the console. It cannot begin with `http://` or `https://`.
    93  
    94      -   `disk_size` (number) - Size of the system disk, in GB, values range:
    95          -   cloud - 5 ~ 2000
    96          -   cloud\_efficiency - 20 ~ 2048
    97          -   cloud\_ssd - 20 ~ 2048
    98  
    99          The value should be equal to or greater than the size of the specific SnapshotId.
   100  
   101      -   `disk_snapshot_id` (string) - Snapshots are used to create the data disk
   102          After this parameter is specified, Size is ignored. The actual size of the
   103          created disk is the size of the specified snapshot.
   104  
   105          Snapshots from on or before July 15, 2013 cannot be used to create a disk.
   106  
   107  -   `image_force_delete` (boolean) - If this value is true, when the target image name
   108      is duplicated with an existing image, it will delete the existing image and
   109      then create the target image, otherwise, the creation will fail. The default
   110      value is false.
   111  
   112  -   `image_force_delete_snapshots` (boolean) - If this value is true, when delete the
   113      duplicated existing image, the source snapshot of this image will be delete
   114      either.
   115  
   116  -   `image_share_account` (array of string) - The IDs of to-be-added Aliyun
   117      accounts to which the image is shared. The number of accounts is 1 to 10. If
   118      number of accounts is greater than 10, this parameter is ignored.
   119  
   120  -   `image_version` (string) - The version number of the image, with a length limit
   121      of 1 to 40 English characters.
   122  
   123  -   `instance_name` (string) - Display name of the instance, which is a string of
   124      2 to 128 Chinese or English characters. It must begin with an
   125      uppercase/lowercase letter or a Chinese character and can contain numerals,
   126      `.`, `_`, or `-`. The instance name is displayed on the Alibaba Cloud
   127      console. If this parameter is not specified, the default value is InstanceId
   128      of the instance. It cannot begin with `http://` or `https://`.
   129  
   130  -   `internet_charge_type` (string) - Internet charge type, which can be
   131      `PayByTraffic` or `PayByBandwidth`. Optional values:
   132      -   PayByBandwidth
   133      -   PayByTraffic
   134  
   135      If this parameter is not specified, the default value is `PayByBandwidth`.
   136      For the regions out of China, currently only support `PayByTraffic`, you must
   137      set it manfully.
   138  
   139  -   `internet_max_bandwidth_out` (string) - Maximum outgoing bandwidth to the public
   140      network, measured in Mbps (Mega bit per second).
   141  
   142      Value range:
   143      -   PayByBandwidth: \[0, 100\]. If this parameter is not specified, API automatically sets it to 0 Mbps.
   144      -   PayByTraffic: \[1, 100\]. If this parameter is not specified, an error is returned.
   145  
   146  -   `io_optimized` (boolean) - Whether an ECS instance is I/O optimized or not.
   147      The default value is `false`.
   148  
   149  -   `security_group_id` (string) - ID of the security group to which a newly
   150      created instance belongs. Mutual access is allowed between instances in one
   151      security group. If not specified, the newly created instance will be added to
   152      the default security group. If the default group doesn’t exist, or the number
   153      of instances in it has reached the maximum limit, a new security group will
   154      be created automatically.
   155  
   156  -   `security_group_name` (string) - The security group name. The default value is
   157      blank. \[2, 128\] English or Chinese characters, must begin with an
   158      uppercase/lowercase letter or Chinese character. Can contain numbers, `.`,
   159      `_` or `-`. It cannot begin with `http://` or `https://`.
   160  
   161  -   `security_token` (string) - STS access token, can be set through template or by exporting
   162       as environment variable such "export SecurityToken=value".
   163  
   164  -   `skip_region_validation` (boolean) - The region validation can be skipped if this
   165      value is true, the default value is false.
   166  
   167  -   `temporary_key_pair_name` (string) - The name of the temporary key pair to
   168      generate. By default, Packer generates a name that looks like `packer_<UUID>`,
   169      where `<UUID>` is a 36 character unique identifier.
   170  
   171  -   `TLSHandshakeTimeout` (int) - When happen "net/http: TLS handshake timeout" problem, set this environment variable
   172       to a bigger such as "export TLSHandshakeTimeout=30", it will set the TLS handshake timeout value to 30s.
   173  
   174  -   `user_data` (string) - The UserData of an instance must be encoded in `Base64`
   175      format, and the maximum size of the raw data is `16 KB`.
   176  
   177  -   `user_data_file` (string) - The file name of the userdata.
   178  
   179  -   `vpc_cidr_block` (string) - Value options: `192.168.0.0/16` and `172.16.0.0/16`.
   180      When not specified, the default value is `172.16.0.0/16`.
   181  
   182  -   `vpc_id` (string) - VPC ID allocated by the system.
   183  
   184  -   `vpc_name` (string) - The VPC name. The default value is blank. \[2, 128\]
   185      English or Chinese characters, must begin with an uppercase/lowercase letter
   186      or Chinese character. Can contain numbers, `_` and `-`. The disk description
   187      will appear on the console. Cannot begin with `http://` or `https://`.
   188  
   189  -   `vswitch_id` (string) - The ID of the VSwitch to be used.
   190  
   191  -   `zone_id` (string) - ID of the zone to which the disk belongs.
   192  
   193  ## Basic Example
   194  
   195  Here is a basic example for Alicloud.
   196  
   197  ``` json
   198  {
   199    "variables": {
   200      "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}",
   201      "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}"
   202    },
   203    "builders": [{
   204      "type":"alicloud-ecs",
   205      "access_key":"{{user `access_key`}}",
   206      "secret_key":"{{user `secret_key`}}",
   207      "region":"cn-beijing",
   208      "image_name":"packer_test2",
   209      "source_image":"centos_7_2_64_40G_base_20170222.vhd",
   210      "ssh_username":"root",
   211      "instance_type":"ecs.n1.tiny",
   212      "io_optimized":"true",
   213      "image_force_delete":"true"
   214    }],
   215    "provisioners": [{
   216      "type": "shell",
   217      "inline": [
   218        "sleep 30",
   219        "yum install redis.x86_64 -y"
   220      ]
   221    }]
   222  }
   223  ```
   224  
   225  See the
   226  [examples/alicloud](https://github.com/hashicorp/packer/tree/master/examples/alicloud)
   227  folder in the packer project for more examples.