Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_db_instance: Move create/delete/update pending states to their own variables and add storage-optimization #2409

Merged
merged 2 commits into from
Dec 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 49 additions & 11 deletions aws/resource_aws_db_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,8 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
"[INFO] Waiting for DB Instance to be available")

stateConf := &resource.StateChangeConf{
Pending: []string{"creating", "backing-up", "modifying", "resetting-master-credentials",
"maintenance", "renaming", "rebooting", "upgrading"},
Target: []string{"available"},
Pending: resourceAwsDbInstanceCreatePendingStates,
Target: []string{"available", "storage-optimization"},
Refresh: resourceAwsDbInstanceStateRefreshFunc(d, meta),
Timeout: d.Timeout(schema.TimeoutCreate),
MinTimeout: 10 * time.Second,
Expand Down Expand Up @@ -687,9 +686,8 @@ func resourceAwsDbInstanceCreate(d *schema.ResourceData, meta interface{}) error
"[INFO] Waiting for DB Instance to be available")

stateConf := &resource.StateChangeConf{
Pending: []string{"creating", "backing-up", "modifying", "resetting-master-credentials",
"maintenance", "renaming", "rebooting", "upgrading", "configuring-enhanced-monitoring"},
Target: []string{"available"},
Pending: resourceAwsDbInstanceCreatePendingStates,
Target: []string{"available", "storage-optimization"},
Refresh: resourceAwsDbInstanceStateRefreshFunc(d, meta),
Timeout: d.Timeout(schema.TimeoutCreate),
MinTimeout: 10 * time.Second,
Expand Down Expand Up @@ -863,8 +861,7 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
log.Println(
"[INFO] Waiting for DB Instance to be destroyed")
stateConf := &resource.StateChangeConf{
Pending: []string{"creating", "backing-up",
"modifying", "deleting", "available"},
Pending: resourceAwsDbInstanceDeletePendingStates,
Target: []string{},
Refresh: resourceAwsDbInstanceStateRefreshFunc(d, meta),
Timeout: d.Timeout(schema.TimeoutDelete),
Expand Down Expand Up @@ -1039,9 +1036,8 @@ func resourceAwsDbInstanceUpdate(d *schema.ResourceData, meta interface{}) error
log.Println("[INFO] Waiting for DB Instance to be available")

stateConf := &resource.StateChangeConf{
Pending: []string{"creating", "backing-up", "modifying", "resetting-master-credentials",
"maintenance", "renaming", "rebooting", "upgrading", "configuring-enhanced-monitoring", "moving-to-vpc"},
Target: []string{"available"},
Pending: resourceAwsDbInstanceUpdatePendingStates,
Target: []string{"available", "storage-optimization"},
Refresh: resourceAwsDbInstanceStateRefreshFunc(d, meta),
Timeout: d.Timeout(schema.TimeoutUpdate),
MinTimeout: 10 * time.Second,
Expand Down Expand Up @@ -1163,3 +1159,45 @@ func buildRDSARN(identifier, partition, accountid, region string) (string, error
arn := fmt.Sprintf("arn:%s:rds:%s:%s:db:%s", partition, region, accountid, identifier)
return arn, nil
}

// Database instance status: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Status.html
var resourceAwsDbInstanceCreatePendingStates = []string{
"backing-up",
"configuring-enhanced-monitoring",
"creating",
"maintenance",
"modifying",
"rebooting",
"renaming",
"resetting-master-credentials",
"starting",
"stopping",
"upgrading",
}

var resourceAwsDbInstanceDeletePendingStates = []string{
"available",
"backing-up",
"configuring-enhanced-monitoring",
"creating",
"deleting",
"modifying",
"starting",
"stopping",
"storage-optimization",
}

var resourceAwsDbInstanceUpdatePendingStates = []string{
"backing-up",
"configuring-enhanced-monitoring",
"creating",
"maintenance",
"modifying",
"moving-to-vpc",
"rebooting",
"renaming",
"resetting-master-credentials",
"starting",
"stopping",
"upgrading",
}