|
|
|
|
@ -9,7 +9,7 @@ import (
|
|
|
|
|
"github.com/mitchellh/goamz/ec2"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestAccAWSRouteTable(t *testing.T) {
|
|
|
|
|
func TestAccAWSRouteTable_normal(t *testing.T) {
|
|
|
|
|
var v ec2.RouteTable
|
|
|
|
|
|
|
|
|
|
testCheck := func(*terraform.State) error {
|
|
|
|
|
@ -81,6 +81,46 @@ func TestAccAWSRouteTable(t *testing.T) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestAccAWSRouteTable_instance(t *testing.T) {
|
|
|
|
|
var v ec2.RouteTable
|
|
|
|
|
|
|
|
|
|
testCheck := func(*terraform.State) error {
|
|
|
|
|
if len(v.Routes) != 2 {
|
|
|
|
|
return fmt.Errorf("bad routes: %#v", v.Routes)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
routes := make(map[string]ec2.Route)
|
|
|
|
|
for _, r := range v.Routes {
|
|
|
|
|
routes[r.DestinationCidrBlock] = r
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if _, ok := routes["10.1.0.0/16"]; !ok {
|
|
|
|
|
return fmt.Errorf("bad routes: %#v", v.Routes)
|
|
|
|
|
}
|
|
|
|
|
if _, ok := routes["10.2.0.0/16"]; !ok {
|
|
|
|
|
return fmt.Errorf("bad routes: %#v", v.Routes)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource.Test(t, resource.TestCase{
|
|
|
|
|
PreCheck: func() { testAccPreCheck(t) },
|
|
|
|
|
Providers: testAccProviders,
|
|
|
|
|
CheckDestroy: testAccCheckRouteTableDestroy,
|
|
|
|
|
Steps: []resource.TestStep{
|
|
|
|
|
resource.TestStep{
|
|
|
|
|
Config: testAccRouteTableConfigInstance,
|
|
|
|
|
Check: resource.ComposeTestCheckFunc(
|
|
|
|
|
testAccCheckRouteTableExists(
|
|
|
|
|
"aws_route_table.foo", &v),
|
|
|
|
|
testCheck,
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func testAccCheckRouteTableDestroy(s *terraform.State) error {
|
|
|
|
|
conn := testAccProvider.ec2conn
|
|
|
|
|
|
|
|
|
|
@ -182,3 +222,30 @@ resource "aws_route_table" "foo" {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
const testAccRouteTableConfigInstance = `
|
|
|
|
|
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}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "aws_route_table" "foo" {
|
|
|
|
|
vpc_id = "${aws_vpc.foo.id}"
|
|
|
|
|
|
|
|
|
|
route {
|
|
|
|
|
cidr_block = "10.2.0.0/16"
|
|
|
|
|
instance_id = "${aws_instance.foo.id}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`
|
|
|
|
|
|