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:
parent
894e6cabbb
commit
84fe0b15fd
|
@ -8,6 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"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/elasticache"
|
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
@ -152,6 +153,10 @@ func testAccCheckAWSElasticacheClusterDestroy(s *terraform.State) error {
|
||||||
CacheClusterId: aws.String(rs.Primary.ID),
|
CacheClusterId: aws.String(rs.Primary.ID),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Verify the error is what we want
|
||||||
|
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "CacheClusterNotFound" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(res.CacheClusters) > 0 {
|
if len(res.CacheClusters) > 0 {
|
||||||
|
|
|
@ -112,7 +112,7 @@ func testAccCheckAWSElasticacheParameterGroupDestroy(s *terraform.State) error {
|
||||||
if !ok {
|
if !ok {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if newerr.Code() != "InvalidCacheParameterGroup.NotFound" {
|
if newerr.Code() != "CacheParameterGroupNotFound" {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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/elasticache"
|
"github.com/aws/aws-sdk-go/service/elasticache"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
@ -71,6 +72,10 @@ func testAccCheckAWSElasticacheSubnetGroupDestroy(s *terraform.State) error {
|
||||||
CacheSubnetGroupName: aws.String(rs.Primary.ID),
|
CacheSubnetGroupName: aws.String(rs.Primary.ID),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Verify the error is what we want
|
||||||
|
if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == "CacheSubnetGroupNotFoundFault" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if len(res.CacheSubnetGroups) > 0 {
|
if len(res.CacheSubnetGroups) > 0 {
|
||||||
|
|
|
@ -247,7 +247,9 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}
|
||||||
|
|
||||||
ds := out.DomainStatus
|
ds := out.DomainStatus
|
||||||
|
|
||||||
d.Set("access_policies", normalizeJson(*ds.AccessPolicies))
|
if ds.AccessPolicies != nil && *ds.AccessPolicies != "" {
|
||||||
|
d.Set("access_policies", normalizeJson(*ds.AccessPolicies))
|
||||||
|
}
|
||||||
err = d.Set("advanced_options", pointersMapToStringList(ds.AdvancedOptions))
|
err = d.Set("advanced_options", pointersMapToStringList(ds.AdvancedOptions))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -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"
|
||||||
elasticsearch "github.com/aws/aws-sdk-go/service/elasticsearchservice"
|
elasticsearch "github.com/aws/aws-sdk-go/service/elasticsearchservice"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
@ -85,8 +86,12 @@ func testAccCheckESDomainDestroy(s *terraform.State) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := conn.DescribeElasticsearchDomain(opts)
|
_, err := conn.DescribeElasticsearchDomain(opts)
|
||||||
|
// Verify the error is what we want
|
||||||
if err != nil {
|
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
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue