Merge pull request #7667 from hashicorp/phinze/skip-final-snapshot-import
provider/aws: Fixup skip_final_snapshot import
This commit is contained in:
commit
71932138b9
|
@ -23,7 +23,10 @@ func TestAccAWSDBInstance_importBasic(t *testing.T) {
|
||||||
ImportState: true,
|
ImportState: true,
|
||||||
ImportStateVerify: true,
|
ImportStateVerify: true,
|
||||||
ImportStateVerifyIgnore: []string{
|
ImportStateVerifyIgnore: []string{
|
||||||
"password", "skip_final_snapshot"},
|
"password",
|
||||||
|
"skip_final_snapshot",
|
||||||
|
"final_snapshot_identifier",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,7 +23,7 @@ func resourceAwsDbInstance() *schema.Resource {
|
||||||
Update: resourceAwsDbInstanceUpdate,
|
Update: resourceAwsDbInstanceUpdate,
|
||||||
Delete: resourceAwsDbInstanceDelete,
|
Delete: resourceAwsDbInstanceDelete,
|
||||||
Importer: &schema.ResourceImporter{
|
Importer: &schema.ResourceImporter{
|
||||||
State: schema.ImportStatePassthrough,
|
State: resourceAwsDbInstanceImport,
|
||||||
},
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
|
@ -757,11 +757,8 @@ func resourceAwsDbInstanceDelete(d *schema.ResourceData, meta interface{}) error
|
||||||
|
|
||||||
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
|
opts := rds.DeleteDBInstanceInput{DBInstanceIdentifier: aws.String(d.Id())}
|
||||||
|
|
||||||
skipFinalSnapshot, exists := d.GetOk("skip_final_snapshot")
|
skipFinalSnapshot := d.Get("skip_final_snapshot").(bool)
|
||||||
if !exists {
|
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot)
|
||||||
skipFinalSnapshot = true
|
|
||||||
}
|
|
||||||
opts.SkipFinalSnapshot = aws.Bool(skipFinalSnapshot.(bool))
|
|
||||||
|
|
||||||
if skipFinalSnapshot == false {
|
if skipFinalSnapshot == false {
|
||||||
if name, present := d.GetOk("final_snapshot_identifier"); present {
|
if name, present := d.GetOk("final_snapshot_identifier"); present {
|
||||||
|
@ -1023,6 +1020,15 @@ func resourceAwsDbInstanceRetrieve(
|
||||||
return resp.DBInstances[0], nil
|
return resp.DBInstances[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resourceAwsDbInstanceImport(
|
||||||
|
d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
|
||||||
|
// Neither skip_final_snapshot nor final_snapshot_identifier can be fetched
|
||||||
|
// from any API call, so we need to default skip_final_snapshot to true so
|
||||||
|
// that final_snapshot_identifier is not required
|
||||||
|
d.Set("skip_final_snapshot", true)
|
||||||
|
return []*schema.ResourceData{d}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func resourceAwsDbInstanceStateRefreshFunc(
|
func resourceAwsDbInstanceStateRefreshFunc(
|
||||||
d *schema.ResourceData, meta interface{}) resource.StateRefreshFunc {
|
d *schema.ResourceData, meta interface{}) resource.StateRefreshFunc {
|
||||||
return func() (interface{}, string, error) {
|
return func() (interface{}, string, error) {
|
||||||
|
|
|
@ -90,8 +90,14 @@ func testStepImportState(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare their attributes
|
// Compare their attributes
|
||||||
actual := r.Primary.Attributes
|
actual := make(map[string]string)
|
||||||
expected := oldR.Primary.Attributes
|
for k, v := range r.Primary.Attributes {
|
||||||
|
actual[k] = v
|
||||||
|
}
|
||||||
|
expected := make(map[string]string)
|
||||||
|
for k, v := range oldR.Primary.Attributes {
|
||||||
|
expected[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
// Remove fields we're ignoring
|
// Remove fields we're ignoring
|
||||||
for _, v := range step.ImportStateVerifyIgnore {
|
for _, v := range step.ImportStateVerifyIgnore {
|
||||||
|
|
Loading…
Reference in New Issue