providers/aws/aws_instance: test modifying source_dest_check
This commit is contained in:
parent
0a6b7a9301
commit
735c909264
|
@ -89,6 +89,7 @@ func resource_aws_instance_update(
|
||||||
if attr, ok := d.Attributes["source_dest_check"]; ok {
|
if attr, ok := d.Attributes["source_dest_check"]; ok {
|
||||||
modify = true
|
modify = true
|
||||||
opts.SourceDestCheck = attr.New != "" && attr.New != "false"
|
opts.SourceDestCheck = attr.New != "" && attr.New != "false"
|
||||||
|
opts.SetSourceDestCheck = true
|
||||||
rs.Attributes["source_dest_check"] = strconv.FormatBool(
|
rs.Attributes["source_dest_check"] = strconv.FormatBool(
|
||||||
opts.SourceDestCheck)
|
opts.SourceDestCheck)
|
||||||
}
|
}
|
||||||
|
@ -98,6 +99,9 @@ func resource_aws_instance_update(
|
||||||
if _, err := ec2conn.ModifyInstance(s.ID, opts); err != nil {
|
if _, err := ec2conn.ModifyInstance(s.ID, opts); err != nil {
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(mitchellh): wait for the attributes we modified to
|
||||||
|
// persist the change...
|
||||||
}
|
}
|
||||||
|
|
||||||
return rs, nil
|
return rs, nil
|
||||||
|
|
|
@ -31,12 +31,14 @@ func TestAccAWSInstance(t *testing.T) {
|
||||||
func TestAccAWSInstance_sourceDestCheck(t *testing.T) {
|
func TestAccAWSInstance_sourceDestCheck(t *testing.T) {
|
||||||
var v ec2.Instance
|
var v ec2.Instance
|
||||||
|
|
||||||
testCheck := func(*terraform.State) error {
|
testCheck := func(enabled bool) resource.TestCheckFunc {
|
||||||
if !v.SourceDestCheck {
|
return func(*terraform.State) error {
|
||||||
return fmt.Errorf("no source_dest_check")
|
if v.SourceDestCheck != enabled {
|
||||||
}
|
return fmt.Errorf("bad source_dest_check: %#v", v.SourceDestCheck)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
|
@ -49,7 +51,16 @@ func TestAccAWSInstance_sourceDestCheck(t *testing.T) {
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckInstanceExists(
|
testAccCheckInstanceExists(
|
||||||
"aws_instance.foo", &v),
|
"aws_instance.foo", &v),
|
||||||
testCheck,
|
testCheck(true),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccInstanceConfigSourceDestDisable,
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckInstanceExists(
|
||||||
|
"aws_instance.foo", &v),
|
||||||
|
testCheck(false),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -161,6 +172,25 @@ resource "aws_instance" "foo" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testAccInstanceConfigSourceDestDisable = `
|
||||||
|
resource "aws_vpc" "foo" {
|
||||||
|
cidr_block = "10.1.0.0/16"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_subnet" "foo" {
|
||||||
|
cidr_block = "10.1.1.0/24"
|
||||||
|
vpc_id = "${aws_vpc.foo.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_instance" "foo" {
|
||||||
|
# us-west-2
|
||||||
|
ami = "ami-4fccb37f"
|
||||||
|
instance_type = "m1.small"
|
||||||
|
subnet_id = "${aws_subnet.foo.id}"
|
||||||
|
source_dest_check = false
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
const testAccInstanceConfigVPC = `
|
const testAccInstanceConfigVPC = `
|
||||||
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