provider/aws: Update ElastiCache tests to verify delete

provider/aws: update elasticache search domain to only save access policies if not empty
This commit is contained in:
clint shryock 2015-12-22 09:02:19 -06:00
parent 894e6cabbb
commit 84fe0b15fd
5 changed files with 20 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/elasticache"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
@ -152,6 +153,10 @@ func testAccCheckAWSElasticacheClusterDestroy(s *terraform.State) error {
CacheClusterId: aws.String(rs.Primary.ID),
})
if err != nil {
// Verify the error is what we want
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "CacheClusterNotFound" {
continue
}
return err
}
if len(res.CacheClusters) > 0 {

View File

@ -112,7 +112,7 @@ func testAccCheckAWSElasticacheParameterGroupDestroy(s *terraform.State) error {
if !ok {
return err
}
if newerr.Code() != "InvalidCacheParameterGroup.NotFound" {
if newerr.Code() != "CacheParameterGroupNotFound" {
return err
}
}

View File

@ -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/elasticache"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
@ -71,6 +72,10 @@ func testAccCheckAWSElasticacheSubnetGroupDestroy(s *terraform.State) error {
CacheSubnetGroupName: aws.String(rs.Primary.ID),
})
if err != nil {
// Verify the error is what we want
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "CacheSubnetGroupNotFoundFault" {
continue
}
return err
}
if len(res.CacheSubnetGroups) > 0 {

View File

@ -247,7 +247,9 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}
ds := out.DomainStatus
if ds.AccessPolicies != nil && *ds.AccessPolicies != "" {
d.Set("access_policies", normalizeJson(*ds.AccessPolicies))
}
err = d.Set("advanced_options", pointersMapToStringList(ds.AdvancedOptions))
if err != nil {
return err

View File

@ -5,6 +5,7 @@ import (
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
elasticsearch "github.com/aws/aws-sdk-go/service/elasticsearchservice"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
@ -85,8 +86,12 @@ func testAccCheckESDomainDestroy(s *terraform.State) error {
}
_, err := conn.DescribeElasticsearchDomain(opts)
// Verify the error is what we want
if err != nil {
return fmt.Errorf("Error describing ES domains: %q", err.Error())
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "ResourceNotFoundException" {
continue
}
return err
}
}
return nil