github.com/ratanraj/packer@v1.3.2/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](../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  -   `disable_stop_instance` (boolean) - If this option is set to `true`, Packer will not stop the instance
    60      for you, and you need to make sure the instance will be stopped in the final provisioner command. Otherwise,
    61      Packer will timeout while waiting the instance to be stopped. This option is provided for some specific
    62      scenarios that you want to stop the instance by yourself. E.g., Sysprep a windows which may shutdown the instance
    63      within its command. The default value is `false`.
    64  
    65  -   `image_copy_names` (array of string) - The name of the destination image, \[2,
    66      128\] English or Chinese characters. It must begin with an uppercase/lowercase
    67      letter or a Chinese character, and may contain numbers, `_` or `-`. It cannot
    68      begin with `http://` or `https://`.
    69  
    70  -   `image_copy_regions` (array of string) - Copy to the destination regionIds.
    71  
    72  -   `image_description` (string) - The description of the image, with a length
    73      limit of 0 to 256 characters. Leaving it blank means null, which is the
    74      default value. It cannot begin with `http://` or `https://`.
    75  
    76  -   `image_disk_mappings` (array of image disk mappings) - Add one or more data disks
    77      to the image.
    78  
    79      -   `disk_category` (string) - Category of the data disk. Optional values are:
    80          -   `cloud` - general cloud disk
    81          -   `cloud_efficiency` - efficiency cloud disk
    82          -   `cloud_ssd` - cloud SSD
    83  
    84          Default value: cloud.
    85  
    86      -   `disk_delete_with_instance` (boolean) - Whether or not the disk is released along with the instance:
    87          -   True indicates that when the instance is released, this disk will be released with it
    88          -   False indicates that when the instance is released, this disk will be retained.
    89  
    90      -   `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://`.
    91  
    92      -   `disk_device` (string) - Device information of the related instance: such as
    93          `/dev/xvdb` It is null unless the Status is In\_use.
    94  
    95      -   `disk_name` (string) - The value of disk name is blank by default. \[2, 128\]
    96          English or Chinese characters, must begin with an uppercase/lowercase letter
    97          or Chinese character. Can contain numbers, `.`, `_` and `-`. The disk name
    98          will appear on the console. It cannot begin with `http://` or `https://`.
    99  
   100      -   `disk_size` (number) - Size of the system disk, in GB, values range:
   101          -   `cloud` - 5 ~ 2000
   102          -   `cloud_efficiency` - 20 ~ 2048
   103          -   `cloud_ssd` - 20 ~ 2048
   104  
   105          The value should be equal to or greater than the size of the specific SnapshotId.
   106  
   107      -   `disk_snapshot_id` (string) - Snapshots are used to create the data disk
   108          After this parameter is specified, Size is ignored. The actual size of the
   109          created disk is the size of the specified snapshot.
   110  
   111          Snapshots from on or before July 15, 2013 cannot be used to create a disk.
   112  
   113  -   `image_force_delete` (boolean) - If this value is true, when the target image name
   114      is duplicated with an existing image, it will delete the existing image and
   115      then create the target image, otherwise, the creation will fail. The default
   116      value is false.
   117  
   118  -   `image_force_delete_snapshots` (boolean) - If this value is true, when delete the
   119      duplicated existing image, the source snapshot of this image will be delete
   120      either.
   121  
   122  -   `image_share_account` (array of string) - The IDs of to-be-added Aliyun
   123      accounts to which the image is shared. The number of accounts is 1 to 10. If
   124      number of accounts is greater than 10, this parameter is ignored.
   125  
   126  -   `image_version` (string) - The version number of the image, with a length limit
   127      of 1 to 40 English characters.
   128  
   129  -   `instance_name` (string) - Display name of the instance, which is a string of
   130      2 to 128 Chinese or English characters. It must begin with an
   131      uppercase/lowercase letter or a Chinese character and can contain numerals,
   132      `.`, `_`, or `-`. The instance name is displayed on the Alibaba Cloud
   133      console. If this parameter is not specified, the default value is InstanceId
   134      of the instance. It cannot begin with `http://` or `https://`.
   135  
   136  -   `internet_charge_type` (string) - Internet charge type, which can be
   137      `PayByTraffic` or `PayByBandwidth`. Optional values:
   138      -   `PayByBandwidth`
   139      -   `PayByTraffic`
   140  
   141      If this parameter is not specified, the default value is `PayByBandwidth`.
   142      For the regions out of China, currently only support `PayByTraffic`, you must
   143      set it manfully.
   144  
   145  -   `internet_max_bandwidth_out` (string) - Maximum outgoing bandwidth to the public
   146      network, measured in Mbps (Mega bits per second).
   147  
   148      Value range:
   149      -   `PayByBandwidth`: \[0, 100\]. If this parameter is not specified, API automatically sets it to 0 Mbps.
   150      -   `PayByTraffic`: \[1, 100\]. If this parameter is not specified, an error is returned.
   151  
   152  -   `io_optimized` (boolean) - Whether an ECS instance is I/O optimized or not.
   153      The default value is `false`.
   154  
   155  -   `security_group_id` (string) - ID of the security group to which a newly
   156      created instance belongs. Mutual access is allowed between instances in one
   157      security group. If not specified, the newly created instance will be added to
   158      the default security group. If the default group doesn’t exist, or the number
   159      of instances in it has reached the maximum limit, a new security group will
   160      be created automatically.
   161  
   162  -   `security_group_name` (string) - The security group name. The default value is
   163      blank. \[2, 128\] English or Chinese characters, must begin with an
   164      uppercase/lowercase letter or Chinese character. Can contain numbers, `.`,
   165      `_` or `-`. It cannot begin with `http://` or `https://`.
   166  
   167  -   `security_token` (string) - STS access token, can be set through template or by exporting
   168       as environment variable such as `export SecurityToken=value`.
   169  
   170  -   `skip_region_validation` (boolean) - The region validation can be skipped if this
   171      value is true, the default value is false.
   172  
   173  -   `temporary_key_pair_name` (string) - The name of the temporary key pair to
   174      generate. By default, Packer generates a name that looks like `packer_<UUID>`,
   175      where `<UUID>` is a 36 character unique identifier.
   176  
   177  -   `TLSHandshakeTimeout` (int) - When happen "net/http: TLS handshake timeout" problem, set this environment variable
   178       to a bigger such as `export TLSHandshakeTimeout=30`, it will set the TLS handshake timeout value to 30s.
   179  
   180  -   `user_data` (string) - The UserData of an instance must be encoded in `Base64`
   181      format, and the maximum size of the raw data is `16 KB`.
   182  
   183  -   `user_data_file` (string) - The file name of the userdata.
   184  
   185  -   `vpc_cidr_block` (string) - Value options: `192.168.0.0/16` and `172.16.0.0/16`.
   186      When not specified, the default value is `172.16.0.0/16`.
   187  
   188  -   `vpc_id` (string) - VPC ID allocated by the system.
   189  
   190  -   `vpc_name` (string) - The VPC name. The default value is blank. \[2, 128\]
   191      English or Chinese characters, must begin with an uppercase/lowercase letter
   192      or Chinese character. Can contain numbers, `_` and `-`. The disk description
   193      will appear on the console. Cannot begin with `http://` or `https://`.
   194  
   195  -   `vswitch_id` (string) - The ID of the VSwitch to be used.
   196  
   197  -   `zone_id` (string) - ID of the zone to which the disk belongs.
   198  
   199  -   `ssh_private_ip` (boolean) - If this value is true, packer will connect to the ECS created through private ip
   200      instead of allocating a public ip or an EIP. The default value is false.
   201  
   202  -   `tags` (object of key/value strings) - Tags applied to the destination image.
   203  
   204  ## Basic Example
   205  
   206  Here is a basic example for Alicloud.
   207  
   208  ``` json
   209  {
   210    "variables": {
   211      "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}",
   212      "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}"
   213    },
   214    "builders": [{
   215      "type":"alicloud-ecs",
   216      "access_key":"{{user `access_key`}}",
   217      "secret_key":"{{user `secret_key`}}",
   218      "region":"cn-beijing",
   219      "image_name":"packer_test2",
   220      "source_image":"centos_7_04_64_20G_alibase_201701015.vhd",
   221      "ssh_username":"root",
   222      "instance_type":"ecs.n1.tiny",
   223      "io_optimized":"true",
   224      "image_force_delete":"true"
   225    }],
   226    "provisioners": [{
   227      "type": "shell",
   228      "inline": [
   229        "sleep 30",
   230        "yum install redis.x86_64 -y"
   231      ]
   232    }]
   233  }
   234  ```
   235  
   236  ~&gt; Note: Images can become deprecated after a while; run
   237  `aliyun ecs DescribeImages` to find one that exists.
   238  
   239  See the
   240  [examples/alicloud](https://github.com/hashicorp/packer/tree/master/examples/alicloud)
   241  folder in the packer project for more examples.