From 51732ac9eb2ddcc29772180686b259e506f454fd Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 22 Dec 2015 07:22:06 -0600 Subject: [PATCH] provider/aws: fix CheckDestroy for codedeploy_app tests --- .../aws/resource_aws_codedeploy_app_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/builtin/providers/aws/resource_aws_codedeploy_app_test.go b/builtin/providers/aws/resource_aws_codedeploy_app_test.go index 6bfa141aea..dd3a4ce7a9 100644 --- a/builtin/providers/aws/resource_aws_codedeploy_app_test.go +++ b/builtin/providers/aws/resource_aws_codedeploy_app_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/codedeploy" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" @@ -40,17 +41,19 @@ func testAccCheckAWSCodeDeployAppDestroy(s *terraform.State) error { continue } - resp, err := conn.GetApplication(&codedeploy.GetApplicationInput{ + _, err := conn.GetApplication(&codedeploy.GetApplicationInput{ ApplicationName: aws.String(rs.Primary.Attributes["name"]), }) - if err == nil { - if resp.Application != nil { - return fmt.Errorf("CodeDeploy app still exists:\n%#v", *resp.Application.ApplicationId) + if err != nil { + // Verify the error is what we want + if ae, ok := err.(awserr.Error); ok && ae.Code() == "ApplicationDoesNotExistException" { + continue } + return err } - return err + return fmt.Errorf("still exists") } return nil