From 8d3f309f62533996b219572bece0173893269eb3 Mon Sep 17 00:00:00 2001 From: clint shryock Date: Tue, 26 Jan 2016 10:35:21 -0600 Subject: [PATCH] provider/aws: Workaround API issue with RDS Cluster DatabaseName --- builtin/providers/aws/resource_aws_rds_cluster.go | 10 +++++++++- builtin/providers/aws/resource_aws_rds_cluster_test.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin/providers/aws/resource_aws_rds_cluster.go b/builtin/providers/aws/resource_aws_rds_cluster.go index 553a85221..45f3531e2 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster.go +++ b/builtin/providers/aws/resource_aws_rds_cluster.go @@ -262,7 +262,15 @@ func resourceAwsRDSClusterRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("availability_zones", aws.StringValueSlice(dbc.AvailabilityZones)); err != nil { return fmt.Errorf("[DEBUG] Error saving AvailabilityZones to state for RDS Cluster (%s): %s", d.Id(), err) } - d.Set("database_name", dbc.DatabaseName) + + // Only set the DatabaseName if it is not nil. There is a known API bug where + // RDS accepts a DatabaseName but does not return it, causing a perpetual + // diff. + // See https://github.com/hashicorp/terraform/issues/4671 for backstory + if dbc.DatabaseName != nil { + d.Set("database_name", dbc.DatabaseName) + } + d.Set("db_subnet_group_name", dbc.DBSubnetGroup) d.Set("endpoint", dbc.Endpoint) d.Set("engine", dbc.Engine) diff --git a/builtin/providers/aws/resource_aws_rds_cluster_test.go b/builtin/providers/aws/resource_aws_rds_cluster_test.go index dfb4fcc51..99693e7e2 100644 --- a/builtin/providers/aws/resource_aws_rds_cluster_test.go +++ b/builtin/providers/aws/resource_aws_rds_cluster_test.go @@ -99,7 +99,7 @@ func testAccCheckAWSClusterDestroy(s *terraform.State) error { // Return nil if the cluster is already destroyed if awsErr, ok := err.(awserr.Error); ok { - if awsErr.Code() == "DBClusterNotFound" { + if awsErr.Code() == "DBClusterNotFoundFault" { return nil } }