provider/aws: fix CheckDestroy for codedeploy_app tests

This commit is contained in:
Paul Hinze 2015-12-22 07:22:06 -06:00
parent 02f14ae34a
commit 51732ac9eb
1 changed files with 8 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "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/aws/aws-sdk-go/service/codedeploy"
"github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform" "github.com/hashicorp/terraform/terraform"
@ -40,17 +41,19 @@ func testAccCheckAWSCodeDeployAppDestroy(s *terraform.State) error {
continue continue
} }
resp, err := conn.GetApplication(&codedeploy.GetApplicationInput{ _, err := conn.GetApplication(&codedeploy.GetApplicationInput{
ApplicationName: aws.String(rs.Primary.Attributes["name"]), ApplicationName: aws.String(rs.Primary.Attributes["name"]),
}) })
if err == nil { if err != nil {
if resp.Application != nil { // Verify the error is what we want
return fmt.Errorf("CodeDeploy app still exists:\n%#v", *resp.Application.ApplicationId) if ae, ok := err.(awserr.Error); ok && ae.Code() == "ApplicationDoesNotExistException" {
continue
} }
return err
} }
return err return fmt.Errorf("still exists")
} }
return nil return nil