Skip to content

Commit 409df48

Browse files
committed
Changes after the feedback from @catsby - these all made perfect sense
1 parent 4e485d4 commit 409df48

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

builtin/providers/aws/resource_aws_rds_cluster.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,17 @@ func resourceAwsRDSCluster() *schema.Resource {
127127
"preferred_backup_window": &schema.Schema{
128128
Type: schema.TypeString,
129129
Optional: true,
130+
Computed: true,
130131
},
131132

132133
"preferred_maintenance_window": &schema.Schema{
133134
Type: schema.TypeString,
134135
Optional: true,
136+
Computed: true,
135137
StateFunc: func(val interface{}) string {
138+
if val == nil {
139+
return ""
140+
}
136141
return strings.ToLower(val.(string))
137142
},
138143
},

builtin/providers/aws/resource_aws_rds_cluster_test.go

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,27 @@ func TestAccAWSRDSCluster_basic(t *testing.T) {
2020
ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
2121
config := fmt.Sprintf(testAccAWSClusterConfig, ri)
2222

23+
resource.Test(t, resource.TestCase{
24+
PreCheck: func() { testAccPreCheck(t) },
25+
Providers: testAccProviders,
26+
CheckDestroy: testAccCheckAWSClusterDestroy,
27+
Steps: []resource.TestStep{
28+
resource.TestStep{
29+
Config: config,
30+
Check: resource.ComposeTestCheckFunc(
31+
testAccCheckAWSClusterExists("aws_rds_cluster.default", &v),
32+
),
33+
},
34+
},
35+
})
36+
}
37+
38+
func TestAccAWSRDSCluster_backups(t *testing.T) {
39+
var v rds.DBCluster
40+
41+
ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
42+
config := fmt.Sprintf(testAccAWSClusterConfig_backups, ri)
43+
2344
resource.Test(t, resource.TestCase{
2445
PreCheck: func() { testAccPreCheck(t) },
2546
Providers: testAccProviders,
@@ -41,12 +62,12 @@ func TestAccAWSRDSCluster_basic(t *testing.T) {
4162
})
4263
}
4364

44-
func TestAccAWSRDSCluster_update(t *testing.T) {
65+
func TestAccAWSRDSCluster_backupsUpdate(t *testing.T) {
4566
var v rds.DBCluster
4667

4768
ri := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
48-
preConfig := fmt.Sprintf(testAccAWSClusterConfig, ri)
49-
postConfig := fmt.Sprintf(testAccAWSClusterConfig_update, ri)
69+
preConfig := fmt.Sprintf(testAccAWSClusterConfig_backups, ri)
70+
postConfig := fmt.Sprintf(testAccAWSClusterConfig_backupsUpdate, ri)
5071

5172
resource.Test(t, resource.TestCase{
5273
PreCheck: func() { testAccPreCheck(t) },
@@ -147,8 +168,16 @@ func testAccCheckAWSClusterExists(n string, v *rds.DBCluster) resource.TestCheck
147168
}
148169
}
149170

150-
// Add some random to the name, to avoid collision
151171
var testAccAWSClusterConfig = `
172+
resource "aws_rds_cluster" "default" {
173+
cluster_identifier = "tf-aurora-cluster-%d"
174+
availability_zones = ["us-west-2a","us-west-2b","us-west-2c"]
175+
database_name = "mydb"
176+
master_username = "foo"
177+
master_password = "mustbeeightcharaters"
178+
}`
179+
180+
var testAccAWSClusterConfig_backups = `
152181
resource "aws_rds_cluster" "default" {
153182
cluster_identifier = "tf-aurora-cluster-%d"
154183
availability_zones = ["us-west-2a","us-west-2b","us-west-2c"]
@@ -160,8 +189,7 @@ resource "aws_rds_cluster" "default" {
160189
preferred_maintenance_window = "tue:04:00-tue:04:30"
161190
}`
162191

163-
// Add some random to the name, to avoid collision
164-
var testAccAWSClusterConfig_update = `
192+
var testAccAWSClusterConfig_backupsUpdate = `
165193
resource "aws_rds_cluster" "default" {
166194
cluster_identifier = "tf-aurora-cluster-%d"
167195
availability_zones = ["us-west-2a","us-west-2b","us-west-2c"]

0 commit comments

Comments
 (0)