Merge pull request #5774 from jwieringa/f-kms-key-id

Added KmsKeyID to Amazon Builder DeviceBlock
This commit is contained in:
Matthew Hooker 2018-01-12 14:23:19 -08:00 committed by GitHub
commit cfd24eddbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11893 additions and 1800 deletions

View File

@ -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
}

View File

@ -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",

View File

@ -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)

File diff suppressed because it is too large Load Diff

View File

@ -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.
//

View File

@ -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
View File

@ -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=",

View File

@ -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)