Fix AWS reporting "The parameter KmsKeyId requires the parameter Encrypted to be set."

- use aws.String/Int/Bool functions
- don't set the key to empty string, use nil instead
This commit is contained in:
Jan Safranek 2016-08-24 10:05:07 +02:00
parent 2fe56d4bb3
commit 8cd5e263b8

View File

@ -1567,18 +1567,16 @@ func (c *Cloud) CreateDisk(volumeOptions *VolumeOptions) (string, error) {
// TODO: Should we tag this with the cluster id (so it gets deleted when the cluster does?) // TODO: Should we tag this with the cluster id (so it gets deleted when the cluster does?)
request := &ec2.CreateVolumeInput{} request := &ec2.CreateVolumeInput{}
request.AvailabilityZone = &createAZ request.AvailabilityZone = aws.String(createAZ)
volSize := int64(volumeOptions.CapacityGB) request.Size = aws.Int64(int64(volumeOptions.CapacityGB))
request.Size = &volSize request.VolumeType = aws.String(createType)
request.VolumeType = &createType request.Encrypted = aws.Bool(volumeOptions.Encrypted)
request.Encrypted = &volumeOptions.Encrypted if len(volumeOptions.KmsKeyId) > 0 {
request.KmsKeyId = &volumeOptions.KmsKeyId request.KmsKeyId = aws.String(volumeOptions.KmsKeyId)
if len(*request.KmsKeyId) > 0 { request.Encrypted = aws.Bool(true)
b := true
request.Encrypted = &b
} }
if iops > 0 { if iops > 0 {
request.Iops = &iops request.Iops = aws.Int64(iops)
} }
response, err := c.ec2.CreateVolume(request) response, err := c.ec2.CreateVolume(request)
if err != nil { if err != nil {