Merge pull request #5774 from jwieringa/f-kms-key-id
Added KmsKeyID to Amazon Builder DeviceBlock
This commit is contained in:
commit
cfd24eddbf
@ -19,6 +19,7 @@ type BlockDevice struct {
|
||||
VirtualName string `mapstructure:"virtual_name"`
|
||||
VolumeType string `mapstructure:"volume_type"`
|
||||
VolumeSize int64 `mapstructure:"volume_size"`
|
||||
KmsKeyId string `mapstructure:"kms_key_id"`
|
||||
}
|
||||
|
||||
type BlockDevices struct {
|
||||
@ -73,6 +74,10 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
|
||||
ebsBlockDevice.Encrypted = aws.Bool(blockDevice.Encrypted)
|
||||
}
|
||||
|
||||
if blockDevice.KmsKeyId != "" {
|
||||
ebsBlockDevice.KmsKeyId = aws.String(blockDevice.KmsKeyId)
|
||||
}
|
||||
|
||||
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{
|
||||
DeviceName: "/dev/sdb",
|
||||
|
@ -57,6 +57,14 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
||||
errs = packer.MultiErrorAppend(errs, b.config.AccessConfig.Prepare(&b.config.ctx)...)
|
||||
errs = packer.MultiErrorAppend(errs, b.config.RunConfig.Prepare(&b.config.ctx)...)
|
||||
|
||||
// Warn that encrypted must be true when setting kms_key_id
|
||||
for _, device := range b.config.VolumeMappings {
|
||||
if device.KmsKeyId != "" && device.Encrypted == false {
|
||||
errs = packer.MultiErrorAppend(errs, fmt.Errorf("The device %v, must also have `encrytped: "+
|
||||
"true` when setting a kms_key_id.", device.DeviceName))
|
||||
}
|
||||
}
|
||||
|
||||
b.config.launchBlockDevices, err = commonBlockDevices(b.config.VolumeMappings, &b.config.ctx)
|
||||
if err != nil {
|
||||
errs = packer.MultiErrorAppend(errs, err)
|
||||
|
13641
vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
generated
vendored
13641
vendor/github.com/aws/aws-sdk-go/service/ec2/api.go
generated
vendored
File diff suppressed because it is too large
Load Diff
2
vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go
generated
vendored
2
vendor/github.com/aws/aws-sdk-go/service/ec2/doc.go
generated
vendored
@ -15,7 +15,7 @@
|
||||
//
|
||||
// Using the Client
|
||||
//
|
||||
// To Amazon Elastic Compute Cloud with the SDK use the New function to create
|
||||
// To contact Amazon Elastic Compute Cloud with the SDK use the New function to create
|
||||
// a new service client. With that client you can make API requests to the service.
|
||||
// These clients are safe to use concurrently.
|
||||
//
|
||||
|
5
vendor/github.com/aws/aws-sdk-go/service/ec2/waiters.go
generated
vendored
5
vendor/github.com/aws/aws-sdk-go/service/ec2/waiters.go
generated
vendored
@ -1025,6 +1025,11 @@ func (c *EC2) WaitUntilSpotInstanceRequestFulfilledWithContext(ctx aws.Context,
|
||||
Matcher: request.PathAllWaiterMatch, Argument: "SpotInstanceRequests[].Status.Code",
|
||||
Expected: "fulfilled",
|
||||
},
|
||||
{
|
||||
State: request.SuccessWaiterState,
|
||||
Matcher: request.PathAllWaiterMatch, Argument: "SpotInstanceRequests[].Status.Code",
|
||||
Expected: "request-canceled-and-instance-running",
|
||||
},
|
||||
{
|
||||
State: request.FailureWaiterState,
|
||||
Matcher: request.PathAnyWaiterMatch, Argument: "SpotInstanceRequests[].Status.Code",
|
||||
|
10
vendor/vendor.json
vendored
10
vendor/vendor.json
vendored
@ -497,13 +497,13 @@
|
||||
"versionExact": "v1.10.23"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "1mbCBXbu6m8bfRAq1+7Cul4VXkU=",
|
||||
"checksumSHA1": "INaeHZ2L5x6RlrcQBm4q1hFqNRM=",
|
||||
"comment": "v1.7.1",
|
||||
"path": "github.com/aws/aws-sdk-go/service/ec2",
|
||||
"revision": "dd3acff9dc16f9a6fd87f6b4501590a532e7206a",
|
||||
"revisionTime": "2017-08-10T20:40:06Z",
|
||||
"version": "v1.10.23",
|
||||
"versionExact": "v1.10.23"
|
||||
"revision": "5177d71d80f123f6d82aaf762387e39b88c5ba23",
|
||||
"revisionTime": "2018-01-09T00:04:15Z",
|
||||
"version": "v1.12.57",
|
||||
"versionExact": "v1.12.57"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "YNq7YhasHn9ceelWX2aG0Cg0Ga0=",
|
||||
|
@ -67,6 +67,7 @@ builder.
|
||||
- `delete_on_termination` (boolean) - Indicates whether the EBS volume is
|
||||
deleted on instance termination
|
||||
- `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
|
||||
volume supports. See the documentation on
|
||||
[IOPs](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_EbsBlockDevice.html)
|
||||
|
Loading…
x
Reference in New Issue
Block a user