up AMIBlockDevices docs

This commit is contained in:
Adrien Delorme 2019-06-18 11:55:12 +02:00
parent 9b75c0af3d
commit 78b29d1a74
1 changed files with 25 additions and 97 deletions

View File

@ -11,50 +11,43 @@ import (
"github.com/hashicorp/packer/template/interpolate" "github.com/hashicorp/packer/template/interpolate"
) )
// BlockDevice // TODO(adrien): doc correctly
type BlockDevice struct { type BlockDevice struct {
// Indicates whether the EBS volume is // Indicates whether the EBS volume is deleted on instance termination.
// deleted on instance termination. Default false. NOTE: If this // Default false. NOTE: If this value is not explicitly set to true and
// value is not explicitly set to true and volumes are not cleaned up by // volumes are not cleaned up by an alternative method, additional volumes
// an alternative method, additional volumes will accumulate after every // will accumulate after every build.
// build.
DeleteOnTermination bool `mapstructure:"delete_on_termination" required:"false"` DeleteOnTermination bool `mapstructure:"delete_on_termination" required:"false"`
// The device name exposed to the instance (for // The device name exposed to the instance (for example, /dev/sdh or xvdh).
// example, /dev/sdh or xvdh). Required for every device in the block // Required for every device in the block device mapping.
// device mapping.
DeviceName string `mapstructure:"device_name" required:"false"` DeviceName string `mapstructure:"device_name" required:"false"`
// Indicates whether or not to encrypt the volume. // Indicates whether or not to encrypt the volume. By default, Packer will
// By default, Packer will keep the encryption setting to what it was in // keep the encryption setting to what it was in the source image. Setting
// the source image. Setting false will result in an unencrypted device, // false will result in an unencrypted device, and true will result in an
// and true will result in an encrypted one. // encrypted one.
Encrypted *bool `mapstructure:"encrypted" required:"false"` Encrypted *bool `mapstructure:"encrypted" required:"false"`
// The number of I/O operations per second (IOPS) that // The number of I/O operations per second (IOPS) that the volume supports.
// the volume supports. See the documentation on // See the documentation on IOPs for more information
// IOPs
// for more information
IOPS int64 `mapstructure:"iops" required:"false"` IOPS int64 `mapstructure:"iops" required:"false"`
// Suppresses the specified device included in the // Suppresses the specified device included in the block device mapping of
// block device mapping of the AMI. // the AMI.
NoDevice bool `mapstructure:"no_device" required:"false"` NoDevice bool `mapstructure:"no_device" required:"false"`
// The ID of the snapshot. // The ID of the snapshot.
SnapshotId string `mapstructure:"snapshot_id" required:"false"` SnapshotId string `mapstructure:"snapshot_id" required:"false"`
// The virtual device name. See the // The virtual device name. See the documentation on Block Device Mapping
// documentation on Block Device
// Mapping
// for more information. // for more information.
VirtualName string `mapstructure:"virtual_name" required:"false"` VirtualName string `mapstructure:"virtual_name" required:"false"`
// The volume type. gp2 for General Purpose // The volume type. gp2 for General Purpose (SSD) volumes, io1 for
// (SSD) volumes, io1 for Provisioned IOPS (SSD) volumes, st1 for // Provisioned IOPS (SSD) volumes, st1 for Throughput Optimized HDD, sc1
// Throughput Optimized HDD, sc1 for Cold HDD, and standard for // for Cold HDD, and standard for Magnetic volumes.
// Magnetic volumes.
VolumeType string `mapstructure:"volume_type" required:"false"` VolumeType string `mapstructure:"volume_type" required:"false"`
// The size of the volume, in GiB. Required if // The size of the volume, in GiB. Required if not specifying a
// not specifying a snapshot_id. // snapshot_id.
VolumeSize int64 `mapstructure:"volume_size" required:"false"` VolumeSize int64 `mapstructure:"volume_size" required:"false"`
// ID, alias or ARN of the KMS key to use for boot // ID, alias or ARN of the KMS key to use for boot volume encryption. This
// volume encryption. This only applies to the main region, other regions // only applies to the main region, other regions where the AMI will be
// where the AMI will be copied will be encrypted by the default EBS KMS key. // copied will be encrypted by the default EBS KMS key. For valid formats
// For valid formats see KmsKeyId in the [AWS API docs - // see KmsKeyId in the [AWS API docs -
// CopyImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopyImage.html) // CopyImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopyImage.html)
// This field is validated by Packer, when using an alias, you will have to // This field is validated by Packer, when using an alias, you will have to
// prefix kms_key_id with alias/. // prefix kms_key_id with alias/.
@ -69,75 +62,10 @@ type BlockDevices struct {
} }
type AMIBlockDevices struct { type AMIBlockDevices struct {
// Add one or more [block device
// mappings](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html)
// to the AMI. These will be attached when booting a new instance from your
// AMI. To add a block device during the Packer build see
// `launch_block_device_mappings` below. Your options here may vary
// depending on the type of VM you use. The block device mappings allow for
// the following configuration:
// - `delete_on_termination` (boolean) - Indicates whether the EBS volume is
// deleted on instance termination. Default `false`. **NOTE**: If this
// value is not explicitly set to `true` and volumes are not cleaned up by
// an alternative method, additional volumes will accumulate after every
// build.
//
// - `device_name` (string) - The device name exposed to the instance (for
// example, `/dev/sdh` or `xvdh`). Required for every device in the block
// device mapping.
//
// - `encrypted` (boolean) - Indicates whether or not to encrypt the volume.
// By default, Packer will keep the encryption setting to what it was in
// the source image. Setting `false` will result in an unencrypted device,
// and `true` will result in an encrypted one.
//
// - `iops` (number) - The number of I/O operations per second (IOPS) that
// the volume supports. See the documentation on
// [IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
// for more information
//
// - `kms_key_id` (string) - The ARN for the KMS encryption key. When
// specifying `kms_key_id`, `encrypted` needs to be set to `true`. For
// valid formats see *KmsKeyId* in the [AWS API docs -
// CopyImage](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CopyImage.html).
//
// - `no_device` (boolean) - Suppresses the specified device included in the
// block device mapping of the AMI.
//
// - `snapshot_id` (string) - The ID of the snapshot.
//
// - `virtual_name` (string) - The virtual device name. See the
// documentation on [Block Device
// Mapping](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_BlockDeviceMapping.html)
// for more information.
//
// - `volume_size` (number) - The size of the volume, in GiB. Required if
// not specifying a `snapshot_id`.
//
// - `volume_type` (string) - The volume type. `gp2` for General Purpose
// (SSD) volumes, `io1` for Provisioned IOPS (SSD) volumes, `st1` for
// Throughput Optimized HDD, `sc1` for Cold HDD, and `standard` for
// Magnetic volumes.
AMIMappings []BlockDevice `mapstructure:"ami_block_device_mappings" required:"false"` AMIMappings []BlockDevice `mapstructure:"ami_block_device_mappings" required:"false"`
} }
type LaunchBlockDevices struct { type LaunchBlockDevices struct {
// Add one or more block devices before the Packer build starts. If you add
// instance store volumes or EBS volumes in addition to the root device
// volume, the created AMI will contain block device mapping information
// for those volumes. Amazon creates snapshots of the source instance's
// root volume and any other EBS volumes described here. When you launch an
// instance from this new AMI, the instance automatically launches with
// these additional volumes, and will restore them from snapshots taken
// from the source instance.
//
// In addition to the fields available in ami_block_device_mappings, you
// may optionally use the following field:
// - `omit_from_artifact` (boolean) - If true, this block device will not
// be snapshotted and the created AMI will not contain block device mapping
// information for this volume. If false, the block device will be mapped
// into the final created AMI. Set this option to true if you need a block
// device mounted in the surrogate AMI but not in the final created AMI.
LaunchMappings []BlockDevice `mapstructure:"launch_block_device_mappings" required:"false"` LaunchMappings []BlockDevice `mapstructure:"launch_block_device_mappings" required:"false"`
} }