Update HCL2 and JSON example for amazon builders (#10645)
* move hcl2 example up over json to amazon-ebs * switch hcl and json templates for all amazon builders * fix json format
This commit is contained in:
parent
6ea7edf4e9
commit
201869d627
|
@ -174,6 +174,16 @@ type AccessConfig struct {
|
|||
// credential types) and GetFederationToken (for federation\_token
|
||||
// credential types) for more details.
|
||||
//
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
// vault_aws_engine {
|
||||
// name = "myrole"
|
||||
// role_arn = "myarn"
|
||||
// ttl = "3600s"
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON example:
|
||||
//
|
||||
// ```json
|
||||
|
@ -185,16 +195,6 @@ type AccessConfig struct {
|
|||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
// vault_aws_engine {
|
||||
// name = "myrole"
|
||||
// role_arn = "myarn"
|
||||
// ttl = "3600s"
|
||||
// }
|
||||
// ```
|
||||
VaultAWSEngine VaultAWSEngineOptions `mapstructure:"vault_aws_engine" required:"false"`
|
||||
// [Polling configuration](#polling-configuration) for the AWS waiter. Configures the waiter that checks
|
||||
// resource state.
|
||||
|
|
|
@ -30,18 +30,6 @@ const (
|
|||
// The following mapping will tell Packer to encrypt the root volume of the
|
||||
// build instance at launch using a specific non-default kms key:
|
||||
//
|
||||
// JSON example:
|
||||
//
|
||||
// ```json
|
||||
// launch_block_device_mappings: [
|
||||
// {
|
||||
// "device_name": "/dev/sda1",
|
||||
// "encrypted": true,
|
||||
// "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d"
|
||||
// }
|
||||
// ]
|
||||
// ```
|
||||
//
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
|
@ -52,6 +40,17 @@ const (
|
|||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON example:
|
||||
// ```json
|
||||
// launch_block_device_mappings: [
|
||||
// {
|
||||
// "device_name": "/dev/sda1",
|
||||
// "encrypted": true,
|
||||
// "kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d"
|
||||
// }
|
||||
// ]
|
||||
// ```
|
||||
//
|
||||
// Please note that the kms_key_id option in this example exists for
|
||||
// launch_block_device_mappings but not ami_block_device_mappings.
|
||||
//
|
||||
|
|
|
@ -132,8 +132,21 @@ type RunConfig struct {
|
|||
// Whether or not to check if the IAM instance profile exists. Defaults to false
|
||||
SkipProfileValidation bool `mapstructure:"skip_profile_validation" required:"false"`
|
||||
// Temporary IAM instance profile policy document
|
||||
// If IamInstanceProfile is specified it will be used instead. Example:
|
||||
// If IamInstanceProfile is specified it will be used instead.
|
||||
//
|
||||
// HCL2 example:
|
||||
// ```hcl
|
||||
//temporary_iam_instance_profile_policy_document {
|
||||
// Statement {
|
||||
// Action = ["logs:*"]
|
||||
// Effect = "Allow"
|
||||
// Resource = "*"
|
||||
// }
|
||||
// Version = "2012-10-17"
|
||||
//}
|
||||
// ```
|
||||
//
|
||||
// JSON example:
|
||||
// ```json
|
||||
//{
|
||||
// "Version": "2012-10-17",
|
||||
|
@ -157,17 +170,7 @@ type RunConfig struct {
|
|||
// The EC2 instance type to use while building the
|
||||
// AMI, such as t2.small.
|
||||
InstanceType string `mapstructure:"instance_type" required:"true"`
|
||||
// Filters used to populate the `security_group_ids` field. JSON Example:
|
||||
//
|
||||
// ```json
|
||||
// {
|
||||
// "security_group_filter": {
|
||||
// "filters": {
|
||||
// "tag:Class": "packer"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
// Filters used to populate the `security_group_ids` field.
|
||||
//
|
||||
// HCL2 Example:
|
||||
//
|
||||
|
@ -179,6 +182,17 @@ type RunConfig struct {
|
|||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON Example:
|
||||
// ```json
|
||||
// {
|
||||
// "security_group_filter": {
|
||||
// "filters": {
|
||||
// "tag:Class": "packer"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// This selects the SG's with tag `Class` with the value `packer`.
|
||||
//
|
||||
// - `filters` (map of strings) - filters used to select a
|
||||
|
@ -213,8 +227,24 @@ type RunConfig struct {
|
|||
// AMI with a root volume snapshot that you have access to.
|
||||
SourceAmi string `mapstructure:"source_ami" required:"true"`
|
||||
// Filters used to populate the `source_ami`
|
||||
// field. JSON Example:
|
||||
// field.
|
||||
//
|
||||
// HCL2 example:
|
||||
// ```hcl
|
||||
// source "amazon-ebs" "basic-example" {
|
||||
// source_ami_filter {
|
||||
// filters = {
|
||||
// virtualization-type = "hvm"
|
||||
// name = "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*"
|
||||
// root-device-type = "ebs"
|
||||
// }
|
||||
// owners = ["099720109477"]
|
||||
// most_recent = true
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON Example:
|
||||
// ```json
|
||||
// "builders" [
|
||||
// {
|
||||
|
@ -231,21 +261,6 @@ type RunConfig struct {
|
|||
// }
|
||||
// ]
|
||||
// ```
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
// source "amazon-ebs" "basic-example" {
|
||||
// source_ami_filter {
|
||||
// filters = {
|
||||
// virtualization-type = "hvm"
|
||||
// name = "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*"
|
||||
// root-device-type = "ebs"
|
||||
// }
|
||||
// owners = ["099720109477"]
|
||||
// most_recent = true
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE:
|
||||
// This will fail unless *exactly* one AMI is returned. In the above example,
|
||||
|
@ -313,8 +328,22 @@ type RunConfig struct {
|
|||
// will allow you to create those programatically.
|
||||
SpotTag config.KeyValues `mapstructure:"spot_tag" required:"false"`
|
||||
// Filters used to populate the `subnet_id` field.
|
||||
// JSON Example:
|
||||
//
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
// source "amazon-ebs" "basic-example" {
|
||||
// subnet_filter {
|
||||
// filters = {
|
||||
// "tag:Class": "build"
|
||||
// }
|
||||
// most_free = true
|
||||
// random = false
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON Example:
|
||||
// ```json
|
||||
// "builders" [
|
||||
// {
|
||||
|
@ -329,19 +358,6 @@ type RunConfig struct {
|
|||
// }
|
||||
// ]
|
||||
// ```
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
// source "amazon-ebs" "basic-example" {
|
||||
// subnet_filter {
|
||||
// filters = {
|
||||
// "tag:Class": "build"
|
||||
// }
|
||||
// most_free = true
|
||||
// random = false
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// This selects the Subnet with tag `Class` with the value `build`, which has
|
||||
// the most free IP addresses. NOTE: This will fail unless *exactly* one
|
||||
|
@ -388,8 +404,21 @@ type RunConfig struct {
|
|||
// data when launching the instance.
|
||||
UserDataFile string `mapstructure:"user_data_file" required:"false"`
|
||||
// Filters used to populate the `vpc_id` field.
|
||||
// JSON Example:
|
||||
//
|
||||
// HCL2 example:
|
||||
// ```hcl
|
||||
// source "amazon-ebs" "basic-example" {
|
||||
// vpc_filter {
|
||||
// filters = {
|
||||
// "tag:Class": "build",
|
||||
// "isDefault": "false",
|
||||
// "cidr": "/24"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON Example:
|
||||
// ```json
|
||||
// "builders" [
|
||||
// {
|
||||
|
@ -404,19 +433,6 @@ type RunConfig struct {
|
|||
// }
|
||||
// ]
|
||||
// ```
|
||||
// HCL2 example:
|
||||
//
|
||||
// ```hcl
|
||||
// source "amazon-ebs" "basic-example" {
|
||||
// vpc_filter {
|
||||
// filters = {
|
||||
// "tag:Class": "build",
|
||||
// "isDefault": "false",
|
||||
// "cidr": "/24"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// This selects the VPC with tag `Class` with the value `build`, which is not
|
||||
// the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail
|
||||
|
|
|
@ -42,17 +42,8 @@ type StateChangeConf struct {
|
|||
|
||||
// Polling configuration for the AWS waiter. Configures the waiter for resources creation or actions like attaching
|
||||
// volumes or importing image.
|
||||
// Usage example:
|
||||
//
|
||||
// In JSON:
|
||||
// ```json
|
||||
// "aws_polling" : {
|
||||
// "delay_seconds": 30,
|
||||
// "max_attempts": 50
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// In HCL2:
|
||||
// HCL2 example:
|
||||
// ```hcl
|
||||
// aws_polling {
|
||||
// delay_seconds = 30
|
||||
|
@ -60,6 +51,13 @@ type StateChangeConf struct {
|
|||
// }
|
||||
// ```
|
||||
//
|
||||
// JSON example:
|
||||
// ```json
|
||||
// "aws_polling" : {
|
||||
// "delay_seconds": 30,
|
||||
// "max_attempts": 50
|
||||
// }
|
||||
// ```
|
||||
type AWSPollingConfig struct {
|
||||
// Specifies the maximum number of attempts the waiter will check for resource state.
|
||||
// This value can also be set via the AWS_MAX_ATTEMPTS.
|
||||
|
|
|
@ -123,19 +123,6 @@ Block devices can be nested in the
|
|||
Here is a basic example. It is completely valid except for the access keys:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-chroot",
|
||||
"access_key": "YOUR KEY HERE",
|
||||
"secret_key": "YOUR SECRET KEY HERE",
|
||||
"source_ami": "ami-e81d5881",
|
||||
"ami_name": "packer-amazon-chroot {{timestamp}}"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -172,6 +159,19 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-chroot",
|
||||
"access_key": "YOUR KEY HERE",
|
||||
"secret_key": "YOUR SECRET KEY HERE",
|
||||
"source_ami": "ami-e81d5881",
|
||||
"ami_name": "packer-amazon-chroot {{timestamp}}"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -193,6 +193,19 @@ the `chroot_mounts` configuration. Here is an example configuration which only
|
|||
mounts `/proc` and `/dev`:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "amazon-chroot" "basic-example" {
|
||||
// ... other builder options
|
||||
chroot_mounts = [
|
||||
["proc", "proc", "/proc"],
|
||||
["bind", "/dev", "/dev"]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -207,19 +220,6 @@ mounts `/proc` and `/dev`:
|
|||
}]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "amazon-chroot" "basic-example" {
|
||||
// ... other builder options
|
||||
chroot_mounts = [
|
||||
["proc", "proc", "/proc"],
|
||||
["bind", "/dev", "/dev"]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -257,26 +257,6 @@ file which will prevent packages installed by your provisioners from starting
|
|||
services:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"echo '#!/bin/sh' > /usr/sbin/policy-rc.d",
|
||||
"echo 'exit 101' >> /usr/sbin/policy-rc.d",
|
||||
"chmod a+x /usr/sbin/policy-rc.d"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": ["rm -f /usr/sbin/policy-rc.d"]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -302,6 +282,26 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"echo '#!/bin/sh' > /usr/sbin/policy-rc.d",
|
||||
"echo 'exit 101' >> /usr/sbin/policy-rc.d",
|
||||
"chmod a+x /usr/sbin/policy-rc.d"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": ["rm -f /usr/sbin/policy-rc.d"]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -321,6 +321,57 @@ involving the `nvme_device_path` option above. Read that for more information.
|
|||
A working example for mounting an NVMe device is below:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
// export PKR_VAR_aws_access_key=$YOURKEY
|
||||
variable "aws_access_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
// export PKR_VAR_aws_secret_key=$YOURSECRETKEY
|
||||
variable "aws_secret_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
data "amazon-ami" "example" {
|
||||
filters = {
|
||||
virtualization-type = "hvm"
|
||||
name = "amzn-ami-hvm-*"
|
||||
root-device-type = "ebs"
|
||||
}
|
||||
owners = ["137112412989"]
|
||||
most_recent = true
|
||||
|
||||
# Access Configuration
|
||||
region = "us-east-1"
|
||||
access_key = var.aws_access_key
|
||||
secret_key = var.aws_secret_key
|
||||
}
|
||||
|
||||
source "amazon-chroot" "basic-example" {
|
||||
access_key = var.aws_access_key
|
||||
secret_key = var.aws_secret_key
|
||||
region = "us-east-1"
|
||||
source_ami = data.amazon-ami.example.id
|
||||
ena_support = true
|
||||
ami_name = "amazon-chroot-test-{{timestamp}}"
|
||||
nvme_device_path = "/dev/nvme1n1p"
|
||||
device_path = "/dev/sdf"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-chroot.basic-example"
|
||||
]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = ["echo Test > /tmp/test.txt"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -357,57 +408,6 @@ A working example for mounting an NVMe device is below:
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
// export PKR_VAR_aws_access_key=$YOURKEY
|
||||
variable "aws_access_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
// export PKR_VAR_aws_secret_key=$YOURSECRETKEY
|
||||
variable "aws_secret_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
source "amazon-chroot" "basic-example" {
|
||||
access_key = var.aws_access_key
|
||||
secret_key = var.aws_secret_key
|
||||
region = "us-east-1"
|
||||
source_ami_filter {
|
||||
filter {
|
||||
key = "virtualization-type"
|
||||
value = "hvm"
|
||||
}
|
||||
filter {
|
||||
key = "name"
|
||||
value = "amzn-ami-hvm-*"
|
||||
}
|
||||
filter {
|
||||
key = "root-device-type"
|
||||
value = "ebs"
|
||||
}
|
||||
owners = ["137112412989"]
|
||||
most_recent = true
|
||||
}
|
||||
ena_support = true
|
||||
ami_name = "amazon-chroot-test-{{timestamp}}"
|
||||
nvme_device_path = "/dev/nvme1n1p"
|
||||
device_path = "/dev/sdf"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-chroot.basic-example"
|
||||
]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = ["echo Test > /tmp/test.txt"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -425,31 +425,6 @@ HVM image and format it ext4. This builder block should be followed by
|
|||
provisioning commands to install the os and bootloader.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-chroot",
|
||||
"ami_name": "packer-from-scratch {{timestamp}}",
|
||||
"from_scratch": true,
|
||||
"ami_virtualization_type": "hvm",
|
||||
"pre_mount_commands": [
|
||||
"parted {{.Device}} mklabel msdos mkpart primary 1M 100% set 1 boot on print",
|
||||
"mkfs.ext4 {{.Device}}1"
|
||||
],
|
||||
"root_volume_size": 15,
|
||||
"root_device_name": "xvda",
|
||||
"ami_block_device_mappings": [
|
||||
{
|
||||
"device_name": "xvda",
|
||||
"delete_on_termination": true,
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -493,6 +468,31 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-chroot",
|
||||
"ami_name": "packer-from-scratch {{timestamp}}",
|
||||
"from_scratch": true,
|
||||
"ami_virtualization_type": "hvm",
|
||||
"pre_mount_commands": [
|
||||
"parted {{.Device}} mklabel msdos mkpart primary 1M 100% set 1 boot on print",
|
||||
"mkfs.ext4 {{.Device}}1"
|
||||
],
|
||||
"root_volume_size": 15,
|
||||
"root_device_name": "xvda",
|
||||
"ami_block_device_mappings": [
|
||||
{
|
||||
"device_name": "xvda",
|
||||
"delete_on_termination": true,
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -535,24 +535,6 @@ The generated variables available for this builder are:
|
|||
Usage example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_path": true,
|
||||
"custom_data": {
|
||||
"source_ami_name": "{{ build `SourceAMIName` }}",
|
||||
"device": "{{ build `Device` }}",
|
||||
"mount_path": "{{ build `MountPath` }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -583,5 +565,23 @@ post-processor "manifest" {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_path": true,
|
||||
"custom_data": {
|
||||
"source_ami_name": "{{ build `SourceAMIName` }}",
|
||||
"device": "{{ build `Device` }}",
|
||||
"mount_path": "{{ build `MountPath` }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
|
|
@ -186,30 +186,6 @@ change the AMI IDs according to what images exist at the time the template is
|
|||
run:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"variables": {
|
||||
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
|
||||
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"access_key": "{{user `aws_access_key`}}",
|
||||
"secret_key": "{{user `aws_secret_key`}}",
|
||||
"region": "us-east-1",
|
||||
"source_ami": "ami-fce3c696",
|
||||
"instance_type": "t2.micro",
|
||||
"ssh_username": "ubuntu",
|
||||
"ami_name": "packer_AWS {{timestamp}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -249,6 +225,30 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"variables": {
|
||||
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
|
||||
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"access_key": "{{user `aws_access_key`}}",
|
||||
"secret_key": "{{user `aws_secret_key`}}",
|
||||
"region": "us-east-1",
|
||||
"source_ami": "ami-fce3c696",
|
||||
"instance_type": "t2.micro",
|
||||
"ssh_username": "ubuntu",
|
||||
"ami_name": "packer_AWS {{timestamp}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -279,6 +279,41 @@ configuration of `launch_block_device_mappings` will expand the root volume
|
|||
`/dev/sdc` when we boot a new instance of our AMI.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
region = "us-east-1"
|
||||
source_ami = "ami-fce3c696"
|
||||
instance_type = "t2.micro"
|
||||
ssh_username = "ubuntu"
|
||||
ami_name = "packer_AWS_example_{{timestamp}}"
|
||||
launch_block_device_mappings {
|
||||
device_name = "/dev/sda1"
|
||||
volume_size = 40
|
||||
volume_type = "gp2"
|
||||
delete_on_termination = true
|
||||
}
|
||||
// Notice that instead of providing a list of mappings, you are just providing
|
||||
// multiple mappings in a row. This diverges from the JSON template format.
|
||||
ami_block_device_mappings {
|
||||
device_name = "/dev/sdb"
|
||||
virtual_name = "ephemeral0"
|
||||
}
|
||||
ami_block_device_mappings {
|
||||
device_name = "/dev/sdc"
|
||||
virtual_name = "ephemeral1"
|
||||
}
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-ebs.basic-example"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -314,41 +349,6 @@ configuration of `launch_block_device_mappings` will expand the root volume
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
region = "us-east-1"
|
||||
source_ami = "ami-fce3c696"
|
||||
instance_type = "t2.micro"
|
||||
ssh_username = "ubuntu"
|
||||
ami_name = "packer_AWS_example_{{timestamp}}"
|
||||
launch_block_device_mappings {
|
||||
device_name = "/dev/sda1"
|
||||
volume_size = 40
|
||||
volume_type = "gp2"
|
||||
delete_on_termination = true
|
||||
}
|
||||
// Notice that instead of providing a list of mappings, you are just providing
|
||||
// multiple mappings in a row. This diverges from the JSON template format.
|
||||
ami_block_device_mappings {
|
||||
device_name = "/dev/sdb"
|
||||
virtual_name = "ephemeral0"
|
||||
}
|
||||
ami_block_device_mappings {
|
||||
device_name = "/dev/sdc"
|
||||
virtual_name = "ephemeral1"
|
||||
}
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-ebs.basic-example"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -400,6 +400,34 @@ The generated variables available for this builder are:
|
|||
Usage example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
# When accessing one of these variables from inside the builder, you need to
|
||||
# use the golang templating syntax. This is due to an architectural quirk that
|
||||
# won't be easily resolvable until legacy json templates are deprecated:
|
||||
build {
|
||||
source "amazon-ebs" "basic-example" {
|
||||
tags = {
|
||||
OS_Version = "Ubuntu"
|
||||
Release = "Latest"
|
||||
Base_AMI_ID = "{{ .SourceAMI }}"
|
||||
Base_AMI_Name = "{{ .SourceAMIName }}"
|
||||
}
|
||||
}
|
||||
|
||||
// when accessing one of the variables from a provisioner or post-processor, use
|
||||
// hcl-syntax
|
||||
post-processor "manifest" {
|
||||
output = "manifest.json"
|
||||
strip_path = true
|
||||
custom_data = {
|
||||
source_ami_name = "${build.SourceAMIName}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -415,35 +443,6 @@ Usage example:
|
|||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
// When accessing one of these variables from inside the builder, you need to
|
||||
// use the golang templating syntax. This is due to an architectural quirk that
|
||||
// won't be easily resolvable until legacy json templates are deprecated:
|
||||
|
||||
{
|
||||
source "amazon-ebs" "basic-example" {
|
||||
tags = {
|
||||
OS_Version = "Ubuntu"
|
||||
Release = "Latest"
|
||||
Base_AMI_ID = "{{ .SourceAMI }}"
|
||||
Base_AMI_Name = "{{ .SourceAMIName }}"
|
||||
}
|
||||
}
|
||||
|
||||
// when accessing one of the variables from a provisioner or post-processor, use
|
||||
// hcl-syntax
|
||||
post-processor "manifest" {
|
||||
output = "manifest.json"
|
||||
strip_path = true
|
||||
custom_data = {
|
||||
source_ami_name = "${build.SourceAMIName}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -455,30 +454,6 @@ provide your access keys, and may need to change the source AMI ID based on
|
|||
what images exist when this template is run:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"region": "us-east-1",
|
||||
"source_ami": "ami-fce3c696",
|
||||
"instance_type": "t2.micro",
|
||||
"ssh_username": "ubuntu",
|
||||
"ami_name": "packer-tag-example {{timestamp}}",
|
||||
"tags": {
|
||||
"OS_Version": "Ubuntu",
|
||||
"Release": "Latest",
|
||||
"Base_AMI_Name": "{{ .SourceAMIName }}",
|
||||
"Extra": "{{ .SourceAMITags.TagName }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -503,6 +478,30 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebs",
|
||||
"region": "us-east-1",
|
||||
"source_ami": "ami-fce3c696",
|
||||
"instance_type": "t2.micro",
|
||||
"ssh_username": "ubuntu",
|
||||
"ami_name": "packer-tag-example {{timestamp}}",
|
||||
"tags": {
|
||||
"OS_Version": "Ubuntu",
|
||||
"Release": "Latest",
|
||||
"Base_AMI_Name": "{{ .SourceAMIName }}",
|
||||
"Extra": "{{ .SourceAMITags.TagName }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -573,6 +572,48 @@ Packer will ask AWS to provide a random password that it generates
|
|||
automatically. The following config will work with the above template:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
# This example uses a amazon-ami data source rather than a specific AMI.
|
||||
# this allows us to use the same filter regardless of what region we're in,
|
||||
# among other benefits.
|
||||
data "amazon-ami" "example" {
|
||||
filters = {
|
||||
virtualization-type = "hvm"
|
||||
name = "*Windows_Server-2012*English-64Bit-Base*"
|
||||
root-device-type = "ebs"
|
||||
}
|
||||
owners = ["amazon"]
|
||||
most_recent = true
|
||||
# Access Region Configuration
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
source "amazon-ebs" "winrm-example" {
|
||||
region = "us-east-1"
|
||||
source_ami = data.amazon-ami.example.id
|
||||
instance_type = "t2.micro"
|
||||
ami_name = "packer_winrm_example {{timestamp}}"
|
||||
# This user data file sets up winrm and configures it so that the connection
|
||||
# from Packer is allowed. Without this file being set, Packer will not
|
||||
# connect to the instance.
|
||||
user_data_file = "../boot_config/winrm_bootstrap.txt"
|
||||
communicator = "winrm"
|
||||
force_deregister = true
|
||||
winrm_insecure = true
|
||||
winrm_username = "Administrator"
|
||||
winrm_use_ssl = true
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-ebs.winrm-example"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -603,51 +644,6 @@ automatically. The following config will work with the above template:
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "winrm-example" {
|
||||
region = "us-east-1"
|
||||
// This example uses a source_ami_filter rather than a specific AMI.
|
||||
// this allows us to use the same filter regardless of what region we're in,
|
||||
// among other benefits.
|
||||
source_ami_filter {
|
||||
filter {
|
||||
key = "virtualization-type"
|
||||
value = "hvm"
|
||||
}
|
||||
filter {
|
||||
key = "name"
|
||||
value = "*Windows_Server-2012*English-64Bit-Base*"
|
||||
}
|
||||
filter {
|
||||
key = "root-device-type"
|
||||
value = "ebs"
|
||||
}
|
||||
most_recent = true
|
||||
owners = ["amazon"]
|
||||
}
|
||||
instance_type = "t2.micro"
|
||||
ami_name = "packer_winrm_example {{timestamp}}"
|
||||
// This user data file sets up winrm and configures it so that the connection
|
||||
// from Packer is allowed. Without this file being set, Packer will not
|
||||
// connect to the instance.
|
||||
user_data_file = "../boot_config/winrm_bootstrap.txt"
|
||||
communicator = "winrm"
|
||||
force_deregister = true
|
||||
winrm_insecure = true
|
||||
winrm_username = "Administrator"
|
||||
winrm_use_ssl = true
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-ebs.winrm-example"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -657,6 +653,18 @@ For Amazon Windows 2016 AMIs it is necessary to run Sysprep commands which can
|
|||
be easily added to the provisioner section.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
provisioner "powershell" {
|
||||
inline = [
|
||||
"C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/InitializeInstance.ps1 -Schedule",
|
||||
"C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/SysprepInstance.ps1 -NoShutdown"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -669,18 +677,6 @@ be easily added to the provisioner section.
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
provisioner "powershell" {
|
||||
inline = [
|
||||
"C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/InitializeInstance.ps1 -Schedule",
|
||||
"C:/ProgramData/Amazon/EC2-Windows/Launch/Scripts/SysprepInstance.ps1 -NoShutdown"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -181,36 +181,6 @@ Block devices can be nested in the
|
|||
## Basic Example
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-ebssurrogate",
|
||||
"secret_key": "YOUR SECRET KEY HERE",
|
||||
"access_key": "YOUR KEY HERE",
|
||||
"region": "us-east-1",
|
||||
"ssh_username": "ubuntu",
|
||||
"instance_type": "t2.medium",
|
||||
"source_ami": "ami-40d28157",
|
||||
"launch_block_device_mappings": [
|
||||
{
|
||||
"volume_type": "gp2",
|
||||
"device_name": "/dev/xvdf",
|
||||
"delete_on_termination": false,
|
||||
"volume_size": 10
|
||||
}
|
||||
],
|
||||
"ami_root_device": {
|
||||
"source_device_name": "/dev/xvdf",
|
||||
"device_name": "/dev/xvda",
|
||||
"delete_on_termination": true,
|
||||
"volume_size": 16,
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -219,7 +189,7 @@ source "amazon-ebssurrogate" "basic-example" {
|
|||
ssh_username = "ubuntu"
|
||||
instance_type = "t2.medium"
|
||||
source_ami = "ami-40d28157"
|
||||
ami_name = "packer-test-adrien"
|
||||
ami_name = "packer-test-ami"
|
||||
ami_virtualization_type = "paravirtual"
|
||||
|
||||
launch_block_device_mappings {
|
||||
|
@ -247,63 +217,128 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebssurrogate",
|
||||
"secret_key": "YOUR SECRET KEY HERE",
|
||||
"access_key": "YOUR KEY HERE",
|
||||
"ami_name": "packer-test-ami",
|
||||
"ami_virtualization_type": "paravirtual",
|
||||
"region": "us-east-1",
|
||||
"ssh_username": "ubuntu",
|
||||
"instance_type": "t2.medium",
|
||||
"source_ami": "ami-40d28157",
|
||||
"launch_block_device_mappings": [
|
||||
{
|
||||
"volume_type": "gp2",
|
||||
"device_name": "/dev/xvdf",
|
||||
"delete_on_termination": false,
|
||||
"volume_size": 10
|
||||
}
|
||||
],
|
||||
"ami_root_device": {
|
||||
"source_device_name": "/dev/xvdf",
|
||||
"device_name": "/dev/xvda",
|
||||
"delete_on_termination": true,
|
||||
"volume_size": 16,
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
-> **Note:** Packer can also read the access key and secret access key from
|
||||
environmental variables. See the configuration reference in the section above
|
||||
for more information on what environmental variables Packer will look for.
|
||||
-> **Note:** Packer can also read the access key and secret access key from
|
||||
environmental variables. See the configuration reference in the section above
|
||||
for more information on what environmental variables Packer will look for.
|
||||
|
||||
Further information on locating AMI IDs and their relationship to instance
|
||||
types and regions can be found in the AWS EC2 Documentation [for
|
||||
Linux](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html)
|
||||
or [for
|
||||
Windows](http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/finding-an-ami.html).
|
||||
Further information on locating AMI IDs and their relationship to instance
|
||||
types and regions can be found in the AWS EC2 Documentation [for
|
||||
Linux](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/finding-an-ami.html)
|
||||
or [for
|
||||
Windows](http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/finding-an-ami.html).
|
||||
|
||||
## Accessing the Instance to Debug
|
||||
## Accessing the Instance to Debug
|
||||
|
||||
If you need to access the instance to debug for some reason, run this builder
|
||||
with the `-debug` flag. In debug mode, the Amazon builder will save the private
|
||||
key in the current directory and will output the DNS or IP information as well.
|
||||
You can use this information to access the instance as it is running.
|
||||
If you need to access the instance to debug for some reason, run this builder
|
||||
with the `-debug` flag. In debug mode, the Amazon builder will save the private
|
||||
key in the current directory and will output the DNS or IP information as well.
|
||||
You can use this information to access the instance as it is running.
|
||||
|
||||
## Build template data
|
||||
## Build template data
|
||||
|
||||
In configuration directives marked as a template engine above, the following
|
||||
variables are available:
|
||||
In configuration directives marked as a template engine above, the following
|
||||
variables are available:
|
||||
|
||||
- `BuildRegion` - The region (for example `eu-central-1`) where Packer is
|
||||
- `BuildRegion` - The region (for example `eu-central-1`) where Packer is
|
||||
building the AMI.
|
||||
- `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build
|
||||
- `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build
|
||||
the AMI.
|
||||
- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`).
|
||||
- `SourceAMIName` - The source AMI Name (for example
|
||||
- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`).
|
||||
- `SourceAMIName` - The source AMI Name (for example
|
||||
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
|
||||
build the AMI.
|
||||
- `SourceAMIOwner` - The source AMI owner ID.
|
||||
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
|
||||
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
|
||||
- `SourceAMIOwner` - The source AMI owner ID.
|
||||
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
|
||||
- `SourceAMITags` - The source AMI Tags, as a `map[string]string` object.
|
||||
|
||||
## Build Shared Information Variables
|
||||
## Build Shared Information Variables
|
||||
|
||||
This builder generates data that are shared with provisioner and post-processor via build function of [template engine](/docs/templates/legacy_json_templates/engine) for JSON and [contextual variables](/docs/templates/hcl_templates/contextual-variables) for HCL2.
|
||||
This builder generates data that are shared with provisioner and post-processor via build function of [template engine](/docs/templates/legacy_json_templates/engine) for JSON and [contextual variables](/docs/templates/hcl_templates/contextual-variables) for HCL2.
|
||||
|
||||
The generated variables available for this builder are:
|
||||
The generated variables available for this builder are:
|
||||
|
||||
- `BuildRegion` - The region (for example `eu-central-1`) where Packer is
|
||||
- `BuildRegion` - The region (for example `eu-central-1`) where Packer is
|
||||
building the AMI.
|
||||
- `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build
|
||||
- `SourceAMI` - The source AMI ID (for example `ami-a2412fcd`) used to build
|
||||
the AMI.
|
||||
- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`).
|
||||
- `SourceAMIName` - The source AMI Name (for example
|
||||
- `SourceAMICreationDate` - The source AMI creation date (for example `"2020-05-14T19:26:34.000Z"`).
|
||||
- `SourceAMIName` - The source AMI Name (for example
|
||||
`ubuntu/images/ebs-ssd/ubuntu-xenial-16.04-amd64-server-20180306`) used to
|
||||
build the AMI.
|
||||
- `SourceAMIOwner` - The source AMI owner ID.
|
||||
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
|
||||
- `SourceAMIOwner` - The source AMI owner ID.
|
||||
- `SourceAMIOwnerName` - The source AMI owner alias/name (for example `amazon`).
|
||||
|
||||
Usage example:
|
||||
Usage example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
// When accessing one of these variables from inside the builder, you need to
|
||||
// use the golang templating syntax. This is due to an architectural quirk that
|
||||
// won't be easily resolvable until legacy json templates are deprecated:
|
||||
|
||||
build {
|
||||
source "amazon-ebs" "basic-example" {
|
||||
tags = {
|
||||
OS_Version = "Ubuntu"
|
||||
Release = "Latest"
|
||||
Base_AMI_ID = "{{ .SourceAMI }}"
|
||||
Base_AMI_Name = "{{ .SourceAMIName }}"
|
||||
}
|
||||
}
|
||||
|
||||
// when accessing one of the variables from a provisioner or post-processor, use
|
||||
// hcl-syntax
|
||||
post-processor "manifest" {
|
||||
output = "manifest.json"
|
||||
strip_path = true
|
||||
custom_data = {
|
||||
source_ami_name = "${build.SourceAMIName}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
|
@ -319,35 +354,6 @@ Usage example:
|
|||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
// When accessing one of these variables from inside the builder, you need to
|
||||
// use the golang templating syntax. This is due to an architectural quirk that
|
||||
// won't be easily resolvable until legacy json templates are deprecated:
|
||||
|
||||
{
|
||||
source "amazon-ebs" "basic-example" {
|
||||
tags = {
|
||||
OS_Version = "Ubuntu"
|
||||
Release = "Latest"
|
||||
Base_AMI_ID = "{{ .SourceAMI }}"
|
||||
Base_AMI_Name = "{{ .SourceAMIName }}"
|
||||
}
|
||||
}
|
||||
|
||||
// when accessing one of the variables from a provisioner or post-processor, use
|
||||
// hcl-syntax
|
||||
post-processor "manifest" {
|
||||
output = "manifest.json"
|
||||
strip_path = true
|
||||
custom_data = {
|
||||
source_ami_name = "${build.SourceAMIName}"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -185,51 +185,6 @@ source "amazon-ebs" "basic-example" {
|
|||
## Basic Example
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-ebsvolume",
|
||||
"region": "us-east-1",
|
||||
"ssh_username": "ubuntu",
|
||||
"instance_type": "t2.medium",
|
||||
"source_ami": "ami-40d28157",
|
||||
"ebs_volumes": [
|
||||
{
|
||||
"volume_type": "gp2",
|
||||
"device_name": "/dev/xvdf",
|
||||
"delete_on_termination": false,
|
||||
"tags": {
|
||||
"zpool": "data",
|
||||
"Name": "Data1"
|
||||
},
|
||||
"volume_size": 10
|
||||
},
|
||||
{
|
||||
"volume_type": "gp2",
|
||||
"device_name": "/dev/xvdg",
|
||||
"tags": {
|
||||
"zpool": "data",
|
||||
"Name": "Data2"
|
||||
},
|
||||
"delete_on_termination": false,
|
||||
"volume_size": 10
|
||||
},
|
||||
{
|
||||
"volume_size": 10,
|
||||
"tags": {
|
||||
"Name": "Data3",
|
||||
"zpool": "data"
|
||||
},
|
||||
"delete_on_termination": false,
|
||||
"device_name": "/dev/xvdh",
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -278,6 +233,55 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebsvolume",
|
||||
"region": "us-east-1",
|
||||
"ssh_username": "ubuntu",
|
||||
"instance_type": "t2.medium",
|
||||
"source_ami": "ami-40d28157",
|
||||
"ebs_volumes": [
|
||||
{
|
||||
"volume_type": "gp2",
|
||||
"device_name": "/dev/xvdf",
|
||||
"delete_on_termination": false,
|
||||
"tags": {
|
||||
"zpool": "data",
|
||||
"Name": "Data1"
|
||||
},
|
||||
"volume_size": 10
|
||||
},
|
||||
{
|
||||
"volume_type": "gp2",
|
||||
"device_name": "/dev/xvdg",
|
||||
"tags": {
|
||||
"zpool": "data",
|
||||
"Name": "Data2"
|
||||
},
|
||||
"delete_on_termination": false,
|
||||
"volume_size": 10
|
||||
},
|
||||
{
|
||||
"volume_size": 10,
|
||||
"tags": {
|
||||
"Name": "Data3",
|
||||
"zpool": "data"
|
||||
},
|
||||
"delete_on_termination": false,
|
||||
"device_name": "/dev/xvdh",
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -351,22 +355,6 @@ The generated variables available for this builder are:
|
|||
Usage example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_path": true,
|
||||
"custom_data": {
|
||||
"source_ami_name": "{{ build `SourceAMIName` }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -395,6 +383,22 @@ post-processor "manifest" {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_path": true,
|
||||
"custom_data": {
|
||||
"source_ami_name": "{{ build `SourceAMIName` }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -142,29 +142,6 @@ Block devices can be nested in the
|
|||
Here is a basic example. It is completely valid except for the access keys:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-instance",
|
||||
"access_key": "YOUR KEY HERE",
|
||||
"secret_key": "YOUR SECRET KEY HERE",
|
||||
"region": "us-east-1",
|
||||
"source_ami": "ami-d9d6a6b0",
|
||||
"instance_type": "m1.small",
|
||||
"ssh_username": "ubuntu",
|
||||
|
||||
"account_id": "0123-4567-0890",
|
||||
"s3_bucket": "packer-images",
|
||||
"x509_cert_path": "x509.cert",
|
||||
"x509_key_path": "x509.key",
|
||||
"x509_upload_path": "/tmp",
|
||||
|
||||
"ami_name": "packer-quick-start {{timestamp}}"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -188,6 +165,29 @@ build {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "amazon-instance",
|
||||
"access_key": "YOUR KEY HERE",
|
||||
"secret_key": "YOUR SECRET KEY HERE",
|
||||
"region": "us-east-1",
|
||||
"source_ami": "ami-d9d6a6b0",
|
||||
"instance_type": "m1.small",
|
||||
"ssh_username": "ubuntu",
|
||||
|
||||
"account_id": "0123-4567-0890",
|
||||
"s3_bucket": "packer-images",
|
||||
"x509_cert_path": "x509.cert",
|
||||
"x509_key_path": "x509.key",
|
||||
"x509_upload_path": "/tmp",
|
||||
|
||||
"ami_name": "packer-quick-start {{timestamp}}"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
@ -239,22 +239,6 @@ The generated variables available for this builder are:
|
|||
Usage example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_path": true,
|
||||
"custom_data": {
|
||||
"source_ami_name": "{{ build `SourceAMIName` }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
|
@ -283,6 +267,22 @@ post-processor "manifest" {
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"post-processors": [
|
||||
{
|
||||
"type": "manifest",
|
||||
"output": "manifest.json",
|
||||
"strip_path": true,
|
||||
"custom_data": {
|
||||
"source_ami_name": "{{ build `SourceAMIName` }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -2,20 +2,19 @@
|
|||
|
||||
Polling configuration for the AWS waiter. Configures the waiter for resources creation or actions like attaching
|
||||
volumes or importing image.
|
||||
Usage example:
|
||||
|
||||
In JSON:
|
||||
```json
|
||||
"aws_polling" : {
|
||||
"delay_seconds": 30,
|
||||
"max_attempts": 50
|
||||
}
|
||||
```
|
||||
|
||||
In HCL2:
|
||||
HCL2 example:
|
||||
```hcl
|
||||
aws_polling {
|
||||
delay_seconds = 30
|
||||
max_attempts = 50
|
||||
}
|
||||
```
|
||||
|
||||
JSON example:
|
||||
```json
|
||||
"aws_polling" : {
|
||||
"delay_seconds": 30,
|
||||
"max_attempts": 50
|
||||
}
|
||||
```
|
||||
|
|
|
@ -66,6 +66,16 @@
|
|||
credential types) and GetFederationToken (for federation\_token
|
||||
credential types) for more details.
|
||||
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
vault_aws_engine {
|
||||
name = "myrole"
|
||||
role_arn = "myarn"
|
||||
ttl = "3600s"
|
||||
}
|
||||
```
|
||||
|
||||
JSON example:
|
||||
|
||||
```json
|
||||
|
@ -77,16 +87,6 @@
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
vault_aws_engine {
|
||||
name = "myrole"
|
||||
role_arn = "myarn"
|
||||
ttl = "3600s"
|
||||
}
|
||||
```
|
||||
|
||||
- `aws_polling` (\*AWSPollingConfig) - [Polling configuration](#polling-configuration) for the AWS waiter. Configures the waiter that checks
|
||||
resource state.
|
||||
|
|
|
@ -8,18 +8,6 @@ Example use case:
|
|||
The following mapping will tell Packer to encrypt the root volume of the
|
||||
build instance at launch using a specific non-default kms key:
|
||||
|
||||
JSON example:
|
||||
|
||||
```json
|
||||
launch_block_device_mappings: [
|
||||
{
|
||||
"device_name": "/dev/sda1",
|
||||
"encrypted": true,
|
||||
"kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
|
@ -30,6 +18,17 @@ launch_block_device_mappings {
|
|||
}
|
||||
```
|
||||
|
||||
JSON example:
|
||||
```json
|
||||
launch_block_device_mappings: [
|
||||
{
|
||||
"device_name": "/dev/sda1",
|
||||
"encrypted": true,
|
||||
"kms_key_id": "1a2b3c4d-5e6f-1a2b-3c4d-5e6f1a2b3c4d"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Please note that the kms_key_id option in this example exists for
|
||||
launch_block_device_mappings but not ami_block_device_mappings.
|
||||
|
||||
|
|
|
@ -71,8 +71,21 @@
|
|||
- `skip_profile_validation` (bool) - Whether or not to check if the IAM instance profile exists. Defaults to false
|
||||
|
||||
- `temporary_iam_instance_profile_policy_document` (\*PolicyDocument) - Temporary IAM instance profile policy document
|
||||
If IamInstanceProfile is specified it will be used instead. Example:
|
||||
If IamInstanceProfile is specified it will be used instead.
|
||||
|
||||
HCL2 example:
|
||||
```hcl
|
||||
temporary_iam_instance_profile_policy_document {
|
||||
Statement {
|
||||
Action = ["logs:*"]
|
||||
Effect = "Allow"
|
||||
Resource = "*"
|
||||
}
|
||||
Version = "2012-10-17"
|
||||
}
|
||||
```
|
||||
|
||||
JSON example:
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
|
@ -92,17 +105,7 @@
|
|||
shutdown in case Packer exits ungracefully. Possible values are stop and
|
||||
terminate. Defaults to stop.
|
||||
|
||||
- `security_group_filter` (SecurityGroupFilterOptions) - Filters used to populate the `security_group_ids` field. JSON Example:
|
||||
|
||||
```json
|
||||
{
|
||||
"security_group_filter": {
|
||||
"filters": {
|
||||
"tag:Class": "packer"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
- `security_group_filter` (SecurityGroupFilterOptions) - Filters used to populate the `security_group_ids` field.
|
||||
|
||||
HCL2 Example:
|
||||
|
||||
|
@ -114,6 +117,17 @@
|
|||
}
|
||||
```
|
||||
|
||||
JSON Example:
|
||||
```json
|
||||
{
|
||||
"security_group_filter": {
|
||||
"filters": {
|
||||
"tag:Class": "packer"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This selects the SG's with tag `Class` with the value `packer`.
|
||||
|
||||
- `filters` (map of strings) - filters used to select a
|
||||
|
@ -144,8 +158,24 @@
|
|||
security_group_id.
|
||||
|
||||
- `source_ami_filter` (AmiFilterOptions) - Filters used to populate the `source_ami`
|
||||
field. JSON Example:
|
||||
field.
|
||||
|
||||
HCL2 example:
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
virtualization-type = "hvm"
|
||||
name = "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*"
|
||||
root-device-type = "ebs"
|
||||
}
|
||||
owners = ["099720109477"]
|
||||
most_recent = true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
JSON Example:
|
||||
```json
|
||||
"builders" [
|
||||
{
|
||||
|
@ -161,21 +191,6 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
virtualization-type = "hvm"
|
||||
name = "ubuntu/images/\*ubuntu-xenial-16.04-amd64-server-\*"
|
||||
root-device-type = "ebs"
|
||||
}
|
||||
owners = ["099720109477"]
|
||||
most_recent = true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This selects the most recent Ubuntu 16.04 HVM EBS AMI from Canonical. NOTE:
|
||||
|
@ -238,8 +253,22 @@
|
|||
will allow you to create those programatically.
|
||||
|
||||
- `subnet_filter` (SubnetFilterOptions) - Filters used to populate the `subnet_id` field.
|
||||
JSON Example:
|
||||
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
subnet_filter {
|
||||
filters = {
|
||||
"tag:Class": "build"
|
||||
}
|
||||
most_free = true
|
||||
random = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
JSON Example:
|
||||
```json
|
||||
"builders" [
|
||||
{
|
||||
|
@ -253,19 +282,6 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
subnet_filter {
|
||||
filters = {
|
||||
"tag:Class": "build"
|
||||
}
|
||||
most_free = true
|
||||
random = false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This selects the Subnet with tag `Class` with the value `build`, which has
|
||||
|
@ -313,8 +329,21 @@
|
|||
data when launching the instance.
|
||||
|
||||
- `vpc_filter` (VpcFilterOptions) - Filters used to populate the `vpc_id` field.
|
||||
JSON Example:
|
||||
|
||||
HCL2 example:
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
vpc_filter {
|
||||
filters = {
|
||||
"tag:Class": "build",
|
||||
"isDefault": "false",
|
||||
"cidr": "/24"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
JSON Example:
|
||||
```json
|
||||
"builders" [
|
||||
{
|
||||
|
@ -329,19 +358,6 @@
|
|||
}
|
||||
]
|
||||
```
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
source "amazon-ebs" "basic-example" {
|
||||
vpc_filter {
|
||||
filters = {
|
||||
"tag:Class": "build",
|
||||
"isDefault": "false",
|
||||
"cidr": "/24"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This selects the VPC with tag `Class` with the value `build`, which is not
|
||||
the default VPC, and have a IPv4 CIDR block of `/24`. NOTE: This will fail
|
||||
|
|
|
@ -15,9 +15,48 @@ To use the session manager as the connection interface for the SSH communicator
|
|||
- `session_manager_port`: A local port on the host machine that should be used as the local end of the session tunnel to the remote host. If not specified Packer will find an available port to use.
|
||||
- `temporary_iam_instance_profile_policy_document`: Creates a temporary instance profile policy document to grant Systems Manager permissions to the Ec2 instance. This is an alternative to using an existing `iam_instance_profile`.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
HCL2 example:
|
||||
|
||||
```hcl
|
||||
# file: example.pkr.hcl
|
||||
|
||||
# In order to get these variables to read from the environment,
|
||||
# set the environment variables to have the same name as the declared
|
||||
# variables, with the prefix PKR_VAR_.
|
||||
# You could also hardcode them into the file, but we recommend that.
|
||||
|
||||
data "amazon-ami" "example" {
|
||||
filters = {
|
||||
virtualization-type = "hvm"
|
||||
name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
|
||||
root-device-type = "ebs"
|
||||
}
|
||||
owners = ["099720109477"]
|
||||
most_recent = true
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
source "amazon-ebs" "ssm-example" {
|
||||
ami_name = "packer_AWS {{timestamp}}"
|
||||
instance_type = "t2.micro"
|
||||
region = "us-east-1"
|
||||
source_ami = data.amazon-ami.example.id
|
||||
ssh_username = "ubuntu"
|
||||
ssh_interface = "session_manager"
|
||||
communicator = "ssh"
|
||||
iam_instance_profile = "myinstanceprofile"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.amazon-ebs.ssm-example"]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = ["echo Connected via SSM at '${build.User}@${build.Host}:${build.Port}'"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
JSON example:
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
|
@ -51,52 +90,6 @@ To use the session manager as the connection interface for the SSH communicator
|
|||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
// In order to get these variables to read from the environment,
|
||||
// set the environment variables to have the same name as the declared
|
||||
// variables, with the prefix PKR_VAR_.
|
||||
|
||||
// You could also hardcode them into the file, but we recommend that.
|
||||
|
||||
|
||||
source "amazon-ebs" "ssm-example" {
|
||||
ami_name = "packer_AWS {{timestamp}}"
|
||||
instance_type = "t2.micro"
|
||||
region = "us-east-1"
|
||||
source_ami_filter {
|
||||
filters = {
|
||||
virtualization-type = "hvm"
|
||||
name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
|
||||
root-device-type = "ebs"
|
||||
}
|
||||
owners = ["099720109477"]
|
||||
most_recent = true
|
||||
}
|
||||
ssh_username = "ubuntu"
|
||||
ssh_interface = "session_manager"
|
||||
communicator = "ssh"
|
||||
iam_instance_profile = "myinstanceprofile"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = [
|
||||
"source.amazon-ebs.ssm-example"
|
||||
]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
"echo Connected via SSM at '${build.User}@${build.Host}:${build.Port}'"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
#### Session Manager Plugin
|
||||
|
||||
Connectivity via the session manager requires the use of a session-manger-plugin, which needs to be installed alongside Packer, and an instance AMI that is capable of running the AWS ssm-agent - see [About SSM Agent](https://docs.aws.amazon.com/systems-manager/latest/userguide/prereqs-ssm-agent.html) for details on supported AMIs.
|
||||
|
|
Loading…
Reference in New Issue