Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_vpc_peering_connection: Allow active pending state during deletion #4140

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions aws/resource_aws_vpc_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,23 @@ func resourceAwsVPCPeeringUpdate(d *schema.ResourceData, meta interface{}) error
func resourceAwsVPCPeeringDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).ec2conn

_, err := conn.DeleteVpcPeeringConnection(
&ec2.DeleteVpcPeeringConnectionInput{
VpcPeeringConnectionId: aws.String(d.Id()),
})
input := &ec2.DeleteVpcPeeringConnectionInput{
VpcPeeringConnectionId: aws.String(d.Id()),
}
log.Printf("[DEBUG] Deleting VPC Peering Connection: %s", input)
_, err := conn.DeleteVpcPeeringConnection(input)
if err != nil {
if isAWSErr(err, "InvalidVpcPeeringConnectionID.NotFound", "") {
return nil
}
return fmt.Errorf("Error deleting VPC Peering Connection (%s): %s", d.Id(), err)
}

// Wait for the vpc peering connection to become available
// Wait for the vpc peering connection to delete
log.Printf("[DEBUG] Waiting for VPC Peering Connection (%s) to delete.", d.Id())
stateConf := &resource.StateChangeConf{
Pending: []string{
ec2.VpcPeeringConnectionStateReasonCodeActive,
ec2.VpcPeeringConnectionStateReasonCodePendingAcceptance,
ec2.VpcPeeringConnectionStateReasonCodeDeleting,
},
Expand All @@ -302,12 +310,10 @@ func resourceAwsVPCPeeringDelete(d *schema.ResourceData, meta interface{}) error
Timeout: 1 * time.Minute,
}
if _, err := stateConf.WaitForState(); err != nil {
return errwrap.Wrapf(fmt.Sprintf(
"Error waiting for VPC Peering Connection (%s) to be deleted: {{err}}",
d.Id()), err)
return fmt.Errorf("Error waiting for VPC Peering Connection (%s) to be deleted: %s", d.Id(), err)
}

return err
return nil
}

// resourceAwsVPCPeeringConnectionStateRefreshFunc returns a resource.StateRefreshFunc that is used to watch
Expand Down