diff --git a/aws/resource_aws_iam_instance_profile.go b/aws/resource_aws_iam_instance_profile.go index ca4a422181eb..d4de93ff67ef 100644 --- a/aws/resource_aws_iam_instance_profile.go +++ b/aws/resource_aws_iam_instance_profile.go @@ -203,8 +203,7 @@ func resourceAwsIamInstanceProfileRead(d *schema.ResourceData, meta interface{}) } result, err := iamconn.GetInstanceProfile(request) - if isAWSErr(err, "NoSuchEntity", "") { - log.Printf("[WARN] IAM Instance Profile %s is already gone", d.Id()) + if isAWSErr(err, iam.ErrCodeNoSuchEntityException, "") { d.SetId("") return nil } @@ -226,6 +225,10 @@ func resourceAwsIamInstanceProfileDelete(d *schema.ResourceData, meta interface{ InstanceProfileName: aws.String(d.Id()), } _, err := iamconn.DeleteInstanceProfile(request) + if isAWSErr(err, iam.ErrCodeNoSuchEntityException, "") { + log.Printf("[WARN] IAM Instance Profile %s is already gone", d.Id()) + return nil + } if err != nil { return fmt.Errorf("Error deleting IAM instance profile %s: %s", d.Id(), err) } diff --git a/aws/resource_aws_iam_instance_profile_test.go b/aws/resource_aws_iam_instance_profile_test.go index 2ec2fc4be5ef..a1f3538bc87a 100644 --- a/aws/resource_aws_iam_instance_profile_test.go +++ b/aws/resource_aws_iam_instance_profile_test.go @@ -125,7 +125,7 @@ func testAccCheckAWSInstanceProfileDestroy(s *terraform.State) error { return fmt.Errorf("still exist.") } - if isAWSErr(err, "NoSuchEntity", "") { + if isAWSErr(err, iam.ErrCodeNoSuchEntityException, "") { continue }