Skip to content

Commit

Permalink
Merge pull request #3490 from hashicorp/b-aws-vpc-peering-checks
Browse files Browse the repository at this point in the history
provider/aws: Additional error checking to VPC Peering conn
  • Loading branch information
catsby committed Oct 13, 2015
2 parents 2f42f58 + 60b7037 commit c0c81dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions builtin/providers/aws/resource_aws_vpc_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
`

Expand Down

0 comments on commit c0c81dc

Please sign in to comment.