Use snapshot size if you don't specify a VolumeSize
This commit is contained in:
parent
2010a0c966
commit
628462b919
|
@ -32,7 +32,6 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
|
|||
for _, blockDevice := range b {
|
||||
ebsBlockDevice := &ec2.EBSBlockDevice{
|
||||
VolumeType: aws.String(blockDevice.VolumeType),
|
||||
VolumeSize: aws.Long(blockDevice.VolumeSize),
|
||||
DeleteOnTermination: aws.Boolean(blockDevice.DeleteOnTermination),
|
||||
}
|
||||
|
||||
|
@ -48,6 +47,11 @@ func buildBlockDevices(b []BlockDevice) []*ec2.BlockDeviceMapping {
|
|||
ebsBlockDevice.Encrypted = aws.Boolean(blockDevice.Encrypted)
|
||||
}
|
||||
|
||||
// Use snapshot size if you don't specify a VolumeSize
|
||||
if blockDevice.VolumeSize != 0 {
|
||||
ebsBlockDevice.VolumeSize = aws.Long(blockDevice.VolumeSize)
|
||||
}
|
||||
|
||||
mapping := &ec2.BlockDeviceMapping{
|
||||
DeviceName: aws.String(blockDevice.DeviceName),
|
||||
VirtualName: aws.String(blockDevice.VirtualName),
|
||||
|
|
|
@ -81,6 +81,22 @@ func TestBlockDevice(t *testing.T) {
|
|||
VirtualName: aws.String("ephemeral0"),
|
||||
},
|
||||
},
|
||||
{
|
||||
Config: &BlockDevice{
|
||||
DeviceName: "/dev/sdb",
|
||||
VolumeType: "standard",
|
||||
DeleteOnTermination: true,
|
||||
},
|
||||
|
||||
Result: &ec2.BlockDeviceMapping{
|
||||
DeviceName: aws.String("/dev/sdb"),
|
||||
VirtualName: aws.String(""),
|
||||
EBS: &ec2.EBSBlockDevice{
|
||||
VolumeType: aws.String("standard"),
|
||||
DeleteOnTermination: aws.Boolean(true),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
|
Loading…
Reference in New Issue