Do not return a root device for instance store backed AMIs. (#9483)
* Do not return a root device for instance store backed AMIs. * Add root EC2 instance store acceptance test.
This commit is contained in:
parent
857d446fd6
commit
8029931086
|
@ -859,6 +859,11 @@ func fetchRootDeviceName(ami string, conn *ec2.EC2) (*string, error) {
|
|||
image := res.Images[0]
|
||||
rootDeviceName := image.RootDeviceName
|
||||
|
||||
// Instance store backed AMIs do not provide a root device name.
|
||||
if *image.RootDeviceType == ec2.DeviceTypeInstanceStore {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Some AMIs have a RootDeviceName like "/dev/sda1" that does not appear as a
|
||||
// DeviceName in the BlockDeviceMapping list (which will instead have
|
||||
// something like "/dev/sda")
|
||||
|
|
|
@ -245,6 +245,46 @@ func TestAccAWSInstance_blockDevices(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestAccAWSInstance_rootInstanceStore(t *testing.T) {
|
||||
var v ec2.Instance
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
IDRefreshName: "aws_instance.foo",
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: `
|
||||
resource "aws_instance" "foo" {
|
||||
# us-west-2
|
||||
# Amazon Linux HVM Instance Store 64-bit (2016.09.0)
|
||||
# https://aws.amazon.com/amazon-linux-ami
|
||||
ami = "ami-44c36524"
|
||||
|
||||
# Only certain instance types support ephemeral root instance stores.
|
||||
# http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/InstanceStorage.html
|
||||
instance_type = "m3.medium"
|
||||
}`,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceExists(
|
||||
"aws_instance.foo", &v),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_instance.foo", "ami", "ami-44c36524"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_instance.foo", "ebs_block_device.#", "0"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_instance.foo", "ebs_optimized", "false"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_instance.foo", "instance_type", "m3.medium"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"aws_instance.foo", "root_block_device.#", "0"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSInstance_sourceDestCheck(t *testing.T) {
|
||||
var v ec2.Instance
|
||||
|
||||
|
|
Loading…
Reference in New Issue