provider/aws: Additional error checking to VPC Peering conn

This commit is contained in:
Clint Shryock 2015-10-13 06:20:46 -05:00
parent 7549872780
commit 60b7037cdd
2 changed files with 8 additions and 5 deletions

View File

@ -127,6 +127,9 @@ func resourceVPCPeeringConnectionAccept(conn *ec2.EC2, id string) (string, error
}
resp, err := conn.AcceptVpcPeeringConnection(req)
if err != nil {
return "", err
}
pc := resp.VpcPeeringConnection
return *pc.Status.Code, err
}
@ -153,16 +156,15 @@ func resourceAwsVPCPeeringUpdate(d *schema.ResourceData, meta interface{}) error
}
pc := pcRaw.(*ec2.VpcPeeringConnection)
if *pc.Status.Code == "pending-acceptance" {
if pc.Status != nil && *pc.Status.Code == "pending-acceptance" {
status, err := resourceVPCPeeringConnectionAccept(conn, d.Id())
log.Printf(
"[DEBUG] VPC Peering connection accept status %s",
status)
if err != nil {
return err
}
log.Printf(
"[DEBUG] VPC Peering connection accept status: %s",
status)
}
}

View File

@ -117,6 +117,7 @@ resource "aws_vpc" "bar" {
resource "aws_vpc_peering_connection" "foo" {
vpc_id = "${aws_vpc.foo.id}"
peer_vpc_id = "${aws_vpc.bar.id}"
auto_accept = true
}
`