providers/aws: route table association tests
This commit is contained in:
parent
450cbba11a
commit
e0bc61d414
|
@ -145,6 +145,7 @@ func resource_aws_route_table_destroy(
|
|||
|
||||
// Do all the disassociations
|
||||
for _, a := range rt.Associations {
|
||||
log.Printf("[INFO] Disassociating association: %s", a.AssociationId)
|
||||
if _, err := ec2conn.DisassociateRouteTable(a.AssociationId); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -55,6 +55,12 @@ func resource_aws_route_table_association_update(
|
|||
rs.ID,
|
||||
rs.Attributes["route_table_id"])
|
||||
if err != nil {
|
||||
ec2err, ok := err.(*ec2.Error)
|
||||
if ok && ec2err.Code == "InvalidAssociationID.NotFound" {
|
||||
// Not found, so just create a new one
|
||||
return resource_aws_route_table_association_create(s, d, meta)
|
||||
}
|
||||
|
||||
return s, err
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func TestAccAWSRouteTableAssociation(t *testing.T) {
|
||||
var v ec2.RouteTable
|
||||
var v, v2 ec2.RouteTable
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -24,6 +24,14 @@ func TestAccAWSRouteTableAssociation(t *testing.T) {
|
|||
"aws_route_table_association.foo", &v),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: testAccRouteTableAssociationConfigChange,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckRouteTableAssociationExists(
|
||||
"aws_route_table_association.foo", &v2),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -112,3 +120,23 @@ resource "aws_route_table_association" "foo" {
|
|||
subnet_id = "${aws_subnet.foo.id}"
|
||||
}
|
||||
`
|
||||
|
||||
const testAccRouteTableAssociationConfigChange = `
|
||||
resource "aws_vpc" "foo" {
|
||||
cidr_block = "10.1.0.0/16"
|
||||
}
|
||||
|
||||
resource "aws_subnet" "foo" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
cidr_block = "10.1.1.0/24"
|
||||
}
|
||||
|
||||
resource "aws_route_table" "bar" {
|
||||
vpc_id = "${aws_vpc.foo.id}"
|
||||
}
|
||||
|
||||
resource "aws_route_table_association" "foo" {
|
||||
route_table_id = "${aws_route_table.bar.id}"
|
||||
subnet_id = "${aws_subnet.foo.id}"
|
||||
}
|
||||
`
|
||||
|
|
|
@ -131,6 +131,10 @@ func resource_aws_subnet_diff(
|
|||
"cidr_block": diff.AttrTypeCreate,
|
||||
"vpc_id": diff.AttrTypeCreate,
|
||||
},
|
||||
|
||||
ComputedAttrs: []string{
|
||||
"availability_zone",
|
||||
},
|
||||
}
|
||||
|
||||
return b.Diff(s, c)
|
||||
|
|
Loading…
Reference in New Issue