packer-cn/website/content/docs/builders/alicloud-ecs.mdx

143 lines
3.7 KiB
Plaintext
Raw Normal View History

2020-03-18 18:46:47 -04:00
---
description: |
The `alicloud-ecs` Packer builder plugin provide the capability to build
customized images based on an existing base images.
page_title: Alicloud Image Builder
sidebar_title: Alicloud ECS
2020-03-18 18:46:47 -04:00
---
# Alicloud Image Builder
Type: `alicloud-ecs`
The `alicloud-ecs` Packer builder plugin provide the capability to build
customized images based on an existing base images.
## Configuration Reference
The following configuration options are available for building Alicloud images.
In addition to the options listed here, a
2020-04-01 15:15:54 -04:00
[communicator](/docs/templates/communicator) can be configured for this
2020-03-18 18:46:47 -04:00
builder.
### Required:
@include 'builder/alicloud/ecs/AlicloudAccessConfig-required.mdx'
2020-03-23 20:02:12 -04:00
@include 'builder/alicloud/ecs/RunConfig-required.mdx'
2020-03-24 19:48:37 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/alicloud/ecs/AlicloudImageConfig-required.mdx'
2020-03-18 18:46:47 -04:00
### Optional:
2020-03-23 20:02:12 -04:00
@include 'builder/alicloud/ecs/AlicloudAccessConfig-not-required.mdx'
2020-03-24 19:48:37 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/alicloud/ecs/AlicloudDiskDevices-not-required.mdx'
2020-03-24 19:48:37 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/alicloud/ecs/RunConfig-not-required.mdx'
2020-03-24 19:48:37 -04:00
2020-03-23 20:02:12 -04:00
@include 'builder/alicloud/ecs/AlicloudImageConfig-not-required.mdx'
2020-03-18 18:46:47 -04:00
@include 'packer-plugin-sdk/communicator/SSHTemporaryKeyPair-not-required.mdx'
@include 'packer-plugin-sdk/communicator/SSH-Key-Pair-Name-not-required.mdx'
@include 'packer-plugin-sdk/communicator/SSH-Private-Key-File-not-required.mdx'
@include 'packer-plugin-sdk/communicator/SSH-Agent-Auth-not-required.mdx'
2020-03-18 18:46:47 -04:00
# Disk Devices Configuration:
2020-12-04 16:00:53 -05:00
@include 'builder/alicloud/ecs/AlicloudDiskDevice-not-required.mdx'
2020-03-18 18:46:47 -04:00
## Basic Example
Here is a basic example for Alicloud.
2020-06-16 11:44:41 -04:00
<Tabs>
<Tab heading="JSON">
2020-03-18 18:46:47 -04:00
```json
{
"variables": {
"access_key": "{{env `ALICLOUD_ACCESS_KEY`}}",
"secret_key": "{{env `ALICLOUD_SECRET_KEY`}}"
},
"builders": [
{
"type": "alicloud-ecs",
"access_key": "{{user `access_key`}}",
"secret_key": "{{user `secret_key`}}",
"region": "cn-beijing",
"image_name": "packer_test2",
"source_image": "centos_7_04_64_20G_alibase_201701015.vhd",
"ssh_username": "root",
"instance_type": "ecs.n1.tiny",
"io_optimized": "true",
"internet_charge_type": "PayByTraffic",
"image_force_delete": "true"
}
],
"provisioners": [
{
"type": "shell",
"inline": ["sleep 30", "yum install redis.x86_64 -y"]
}
]
}
```
2020-06-16 11:44:41 -04:00
</Tab>
<Tab heading="HCL2">
```hcl
variable "access_key" {
type = string
}
variable "secret_key" {
type = string
}
source "alicloud-ecs" "basic-example" {
access_key = var.access_key
secret_key = var.secret_key
region = "cn-beijing"
image_name = "packer_test2"
source_image = "centos_7_04_64_20G_alibase_201701015.vhd"
ssh_username = "root"
instance_type = "ecs.n1.tiny"
io_optimized = true
internet_charge_type = "PayByTraffic"
image_force_delete = true
}
build {
sources = ["sources.alicloud-ecs.basic-example"]
provisioner "shell" {
inline = [
"sleep 30", "yum install redis.x86_64 -y",
]
}
}
```
</Tab>
</Tabs>
2020-03-23 20:02:12 -04:00
~> Note: Images can become deprecated after a while; run
2020-03-18 18:46:47 -04:00
`aliyun ecs DescribeImages` to find one that exists.
2020-03-23 20:02:12 -04:00
~> Note: Since WinRM is closed by default in the system image. If you are
2020-03-18 18:46:47 -04:00
planning to use Windows as the base image, you need enable it by userdata in
order to connect to the instance, check
[alicloud_windows.json](https://github.com/hashicorp/packer/tree/master/examples/alicloud/basic/alicloud_windows.json)
and
[winrm_enable_userdata.ps1](https://github.com/hashicorp/packer/tree/master/examples/alicloud/basic/winrm_enable_userdata.ps1)
for details.
See the
[examples/alicloud](https://github.com/hashicorp/packer/tree/master/examples/alicloud)
folder in the packer project for more examples.