From cc2a5ab18f4a49ac0ebef399b9d496caf6c07262 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 28 Jun 2015 22:30:43 -0700 Subject: [PATCH] provider/aws: ignore association not exist on EIP destroy [GH-2295] --- builtin/providers/aws/resource_aws_eip.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builtin/providers/aws/resource_aws_eip.go b/builtin/providers/aws/resource_aws_eip.go index 2b9125944..f4b335a1e 100644 --- a/builtin/providers/aws/resource_aws_eip.go +++ b/builtin/providers/aws/resource_aws_eip.go @@ -222,6 +222,17 @@ func resourceAwsEipDelete(d *schema.ResourceData, meta interface{}) error { PublicIP: aws.String(d.Get("public_ip").(string)), }) } + + if err != nil { + // First check if the association ID is not found. If this + // is the case, then it was already disassociated somehow, + // and that is okay. The most commmon reason for this is that + // the instance or ENI it was attached it was destroyed. + if ec2err, ok := err.(awserr.Error); ok && ec2err.Code() == "InvalidAssociationID.NotFound" { + err = nil + } + } + if err != nil { return err }