Skip to content

Commit

Permalink
Merge pull request #7426 from sklarsa/snapshot-fix
Browse files Browse the repository at this point in the history
Fixes creating aws_db_instance from snapshot with iops
  • Loading branch information
bflad authored Feb 22, 2019
2 parents 02995bc + 2eb4e85 commit eedd907
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions aws/resource_aws_db_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,33 @@ func TestAccAWSDBInstance_SnapshotIdentifier_AllocatedStorage(t *testing.T) {
})
}

func TestAccAWSDBInstance_SnapshotIdentifier_Io1Storage(t *testing.T) {
var dbInstance, sourceDbInstance rds.DBInstance
var dbSnapshot rds.DBSnapshot

rName := acctest.RandomWithPrefix("tf-acc-test")
sourceDbResourceName := "aws_db_instance.source"
snapshotResourceName := "aws_db_snapshot.test"
resourceName := "aws_db_instance.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSDBInstanceConfig_SnapshotIdentifier_Io1Storage(rName, 1000),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSDBInstanceExists(sourceDbResourceName, &sourceDbInstance),
testAccCheckDbSnapshotExists(snapshotResourceName, &dbSnapshot),
testAccCheckAWSDBInstanceExists(resourceName, &dbInstance),
resource.TestCheckResourceAttr(resourceName, "iops", "1000"),
),
},
},
})
}

func TestAccAWSDBInstance_SnapshotIdentifier_AutoMinorVersionUpgrade(t *testing.T) {
var dbInstance, sourceDbInstance rds.DBInstance
var dbSnapshot rds.DBSnapshot
Expand Down Expand Up @@ -3848,6 +3875,35 @@ resource "aws_db_instance" "test" {
`, rName, rName, allocatedStorage, rName)
}

func testAccAWSDBInstanceConfig_SnapshotIdentifier_Io1Storage(rName string, iops int) string {
return fmt.Sprintf(`
resource "aws_db_instance" "source" {
allocated_storage = 200
engine = "mariadb"
identifier = "%s-source"
instance_class = "db.t2.micro"
password = "avoid-plaintext-passwords"
username = "tfacctest"
skip_final_snapshot = true
}
resource "aws_db_snapshot" "test" {
db_instance_identifier = "${aws_db_instance.source.id}"
db_snapshot_identifier = %q
}
resource "aws_db_instance" "test" {
identifier = %q
instance_class = "${aws_db_instance.source.instance_class}"
snapshot_identifier = "${aws_db_snapshot.test.id}"
skip_final_snapshot = true
allocated_storage = 200
iops = %d
storage_type = "io1"
}
`, rName, rName, rName, iops)
}

func testAccAWSDBInstanceConfig_SnapshotIdentifier_AutoMinorVersionUpgrade(rName string, autoMinorVersionUpgrade bool) string {
return fmt.Sprintf(`
resource "aws_db_instance" "source" {
Expand Down

0 comments on commit eedd907

Please sign in to comment.