builder/amazon: Added KmsKeyID to BlockDevice
+ Adds kms_key_id to list of options + Tests that configuraiton is set along with encrypted + Updates documentation on ebsvolume builder
This commit is contained in:
parent
78ff4d1eed
commit
2ac59b3c27
|
@ -19,6 +19,7 @@ type BlockDevice struct {
|
||||||
VirtualName string `mapstructure:"virtual_name"`
|
VirtualName string `mapstructure:"virtual_name"`
|
||||||
VolumeType string `mapstructure:"volume_type"`
|
VolumeType string `mapstructure:"volume_type"`
|
||||||
VolumeSize int64 `mapstructure:"volume_size"`
|
VolumeSize int64 `mapstructure:"volume_size"`
|
||||||
|
KmsKeyId string `mapstructure:"kms_key_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BlockDevices struct {
|
type BlockDevices struct {
|
||||||
|
@ -73,6 +74,10 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
|
||||||
ebsBlockDevice.Encrypted = aws.Bool(blockDevice.Encrypted)
|
ebsBlockDevice.Encrypted = aws.Bool(blockDevice.Encrypted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if blockDevice.KmsKeyId != "" {
|
||||||
|
ebsBlockDevice.KmsKeyId = aws.String(blockDevice.KmsKeyId)
|
||||||
|
}
|
||||||
|
|
||||||
mapping.Ebs = ebsBlockDevice
|
mapping.Ebs = ebsBlockDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,27 @@ func TestBlockDevice(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Config: &BlockDevice{
|
||||||
|
DeviceName: "/dev/sdb",
|
||||||
|
VolumeType: "gp2",
|
||||||
|
VolumeSize: 8,
|
||||||
|
DeleteOnTermination: true,
|
||||||
|
Encrypted: true,
|
||||||
|
KmsKeyId: "2Fa48a521f-3aff-4b34-a159-376ac5d37812",
|
||||||
|
},
|
||||||
|
|
||||||
|
Result: &ec2.BlockDeviceMapping{
|
||||||
|
DeviceName: aws.String("/dev/sdb"),
|
||||||
|
Ebs: &ec2.EbsBlockDevice{
|
||||||
|
VolumeType: aws.String("gp2"),
|
||||||
|
VolumeSize: aws.Int64(8),
|
||||||
|
DeleteOnTermination: aws.Bool(true),
|
||||||
|
Encrypted: aws.Bool(true),
|
||||||
|
KmsKeyId: aws.String("2Fa48a521f-3aff-4b34-a159-376ac5d37812"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Config: &BlockDevice{
|
Config: &BlockDevice{
|
||||||
DeviceName: "/dev/sdb",
|
DeviceName: "/dev/sdb",
|
||||||
|
|
|
@ -67,6 +67,7 @@ builder.
|
||||||
- `delete_on_termination` (boolean) - Indicates whether the EBS volume is
|
- `delete_on_termination` (boolean) - Indicates whether the EBS volume is
|
||||||
deleted on instance termination
|
deleted on instance termination
|
||||||
- `encrypted` (boolean) - Indicates whether to encrypt the volume or not
|
- `encrypted` (boolean) - Indicates whether to encrypt the volume or not
|
||||||
|
- `kms_key_id` (string) - The ARN for the KMS encryption key. When specifying kms_key_id, encrypted needs to be set to true.
|
||||||
- `iops` (number) - The number of I/O operations per second (IOPS) that the
|
- `iops` (number) - The number of I/O operations per second (IOPS) that the
|
||||||
volume supports. See the documentation on
|
volume supports. See the documentation on
|
||||||
[IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
|
[IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
|
||||||
|
|
Loading…
Reference in New Issue