Merge pull request #3490 from hashicorp/b-aws-vpc-peering-checks

provider/aws: Additional error checking to VPC Peering conn
This commit is contained in:
Clint 2015-10-13 12:55:45 -05:00
commit c0c81dc78f
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) resp, err := conn.AcceptVpcPeeringConnection(req)
if err != nil {
return "", err
}
pc := resp.VpcPeeringConnection pc := resp.VpcPeeringConnection
return *pc.Status.Code, err return *pc.Status.Code, err
} }
@ -153,16 +156,15 @@ func resourceAwsVPCPeeringUpdate(d *schema.ResourceData, meta interface{}) error
} }
pc := pcRaw.(*ec2.VpcPeeringConnection) 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()) status, err := resourceVPCPeeringConnectionAccept(conn, d.Id())
log.Printf(
"[DEBUG] VPC Peering connection accept status %s",
status)
if err != nil { if err != nil {
return err 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" { resource "aws_vpc_peering_connection" "foo" {
vpc_id = "${aws_vpc.foo.id}" vpc_id = "${aws_vpc.foo.id}"
peer_vpc_id = "${aws_vpc.bar.id}" peer_vpc_id = "${aws_vpc.bar.id}"
auto_accept = true
} }
` `