tests for aws instance block_device
This commit is contained in:
parent
fc58d0a977
commit
9fa25c40b2
|
@ -64,6 +64,44 @@ func TestAccAWSInstance_normal(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccAWSInstance_blockDevicesCheck(t *testing.T) {
|
||||||
|
var v ec2.Instance
|
||||||
|
|
||||||
|
testCheck := func() resource.TestCheckFunc {
|
||||||
|
return func(*terraform.State) error {
|
||||||
|
|
||||||
|
// Map out the block devices by name, which should be unique.
|
||||||
|
blockDevices := make(map[string]ec2.BlockDevice)
|
||||||
|
for _, blockDevice := range v.BlockDevices {
|
||||||
|
blockDevices[blockDevice.DeviceName] = blockDevice
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the secondary block device exists.
|
||||||
|
if _, ok := blockDevices["/dev/sdb"]; !ok {
|
||||||
|
fmt.Errorf("block device doesn't exist: /dev/sdb")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckInstanceDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccInstanceConfigBlockDevices,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckInstanceExists(
|
||||||
|
"aws_instance.foo", &v),
|
||||||
|
testCheck(),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func TestAccAWSInstance_sourceDestCheck(t *testing.T) {
|
func TestAccAWSInstance_sourceDestCheck(t *testing.T) {
|
||||||
var v ec2.Instance
|
var v ec2.Instance
|
||||||
|
|
||||||
|
@ -233,6 +271,19 @@ resource "aws_instance" "foo" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testAccInstanceConfigBlockDevices = `
|
||||||
|
resource "aws_instance" "foo" {
|
||||||
|
# us-west-2
|
||||||
|
ami = "ami-55a7ea65"
|
||||||
|
instance_type = "m1.small"
|
||||||
|
block_device {
|
||||||
|
device_name = "/dev/sdb"
|
||||||
|
volume_type = "gp2"
|
||||||
|
volume_size = 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
const testAccInstanceConfigSourceDest = `
|
const testAccInstanceConfigSourceDest = `
|
||||||
resource "aws_vpc" "foo" {
|
resource "aws_vpc" "foo" {
|
||||||
cidr_block = "10.1.0.0/16"
|
cidr_block = "10.1.0.0/16"
|
||||||
|
|
Loading…
Reference in New Issue