From 7fcf32e5db7096b815b3a1a70e06f864276ee45a Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Tue, 12 Jul 2022 23:19:34 +0200 Subject: [PATCH 1/8] Add default timeout to the `aws_db_instance_automated_backups_replication` schema --- .../service/rds/instance_automated_backups_replication.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/service/rds/instance_automated_backups_replication.go b/internal/service/rds/instance_automated_backups_replication.go index 2e1840eeae4f..f99597b06518 100644 --- a/internal/service/rds/instance_automated_backups_replication.go +++ b/internal/service/rds/instance_automated_backups_replication.go @@ -3,6 +3,7 @@ package rds import ( "fmt" "log" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" @@ -19,6 +20,12 @@ func ResourceInstanceAutomatedBackupsReplication() *schema.Resource { Read: resourceInstanceAutomatedBackupsReplicationRead, Delete: resourceInstanceAutomatedBackupsReplicationDelete, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(75 * time.Minute), + Update: schema.DefaultTimeout(75 * time.Minute), + Delete: schema.DefaultTimeout(75 * time.Minute), + }, + Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, From ad9be8643d9d9a92b8e121ac0a5efb9466e4b4b8 Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Tue, 12 Jul 2022 23:19:51 +0200 Subject: [PATCH 2/8] Add `#Timeouts` section to the `aws_db_instance_automated_backups_replication` resource docs --- .../r/db_instance_automated_backups_replication.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/website/docs/r/db_instance_automated_backups_replication.markdown b/website/docs/r/db_instance_automated_backups_replication.markdown index 20f9129972e4..7b1ae0dedaab 100644 --- a/website/docs/r/db_instance_automated_backups_replication.markdown +++ b/website/docs/r/db_instance_automated_backups_replication.markdown @@ -87,6 +87,15 @@ In addition to all arguments above, the following attributes are exported: * `id` - The Amazon Resource Name (ARN) of the replicated automated backups. +## Timeouts + +`aws_db_instance_automated_backups_replication` provides the following [Timeouts](https://www.terraform.io/docs/configuration/blocks/resources/syntax.html#operation-timeouts) +configuration options: + +- `create` - (Default `75m`) How long to wait before RDS initiates the automated backup replication. +- `update` - (Default `75m`) How long to wait before RDS updates the automated backup replication. +- `delete` - (Default `75m`) How long to wait before RDS deletes the automated backup replication. + ## Import RDS instance automated backups replication can be imported using the `arn`, e.g., From f12b0adddc9e99d40acfd67cc26848ea57d4d75e Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Tue, 12 Jul 2022 23:23:38 +0200 Subject: [PATCH 3/8] Update timeout descriptions in `aws_db_instance_automated_backups_replication` docs --- .../r/db_instance_automated_backups_replication.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/r/db_instance_automated_backups_replication.markdown b/website/docs/r/db_instance_automated_backups_replication.markdown index 7b1ae0dedaab..fe72467c56b8 100644 --- a/website/docs/r/db_instance_automated_backups_replication.markdown +++ b/website/docs/r/db_instance_automated_backups_replication.markdown @@ -92,9 +92,9 @@ In addition to all arguments above, the following attributes are exported: `aws_db_instance_automated_backups_replication` provides the following [Timeouts](https://www.terraform.io/docs/configuration/blocks/resources/syntax.html#operation-timeouts) configuration options: -- `create` - (Default `75m`) How long to wait before RDS initiates the automated backup replication. -- `update` - (Default `75m`) How long to wait before RDS updates the automated backup replication. -- `delete` - (Default `75m`) How long to wait before RDS deletes the automated backup replication. +- `create` - (Default `75m`) How long to wait before RDS successfully starts replication of automated backups to a different AWS Region. +- `update` - (Default `75m`) How long to wait before RDS completes updating existing replication of automated backups to a different AWS Region. +- `delete` - (Default `75m`) How long to wait before RDS stops automated backup replication for a DB instance. ## Import From 6b0beed8fe7b406b02ac95e0adc78c49548c438f Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Wed, 13 Jul 2022 11:10:57 +0200 Subject: [PATCH 4/8] Remove Update timeout and use constants --- .../rds/instance_automated_backups_replication.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/service/rds/instance_automated_backups_replication.go b/internal/service/rds/instance_automated_backups_replication.go index f99597b06518..5aa39532035e 100644 --- a/internal/service/rds/instance_automated_backups_replication.go +++ b/internal/service/rds/instance_automated_backups_replication.go @@ -14,6 +14,11 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/verify" ) +const ( + InstanceAutomatedBackupsReplicationCreateTimeout = 75 * time.Minute + InstanceAutomatedBackupsReplicationDeleteTimeout = 75 * time.Minute +) + func ResourceInstanceAutomatedBackupsReplication() *schema.Resource { return &schema.Resource{ Create: resourceInstanceAutomatedBackupsReplicationCreate, @@ -21,9 +26,8 @@ func ResourceInstanceAutomatedBackupsReplication() *schema.Resource { Delete: resourceInstanceAutomatedBackupsReplicationDelete, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(75 * time.Minute), - Update: schema.DefaultTimeout(75 * time.Minute), - Delete: schema.DefaultTimeout(75 * time.Minute), + Create: schema.DefaultTimeout(InstanceAutomatedBackupsReplicationCreateTimeout), + Delete: schema.DefaultTimeout(InstanceAutomatedBackupsReplicationDeleteTimeout), }, Importer: &schema.ResourceImporter{ From aedd943c997ff93095bc81d5fa2881303f95c1fa Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Wed, 13 Jul 2022 11:12:33 +0200 Subject: [PATCH 5/8] Remove delete from Timeout section in `db_instance_automated_backups_replication` docs --- .../docs/r/db_instance_automated_backups_replication.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/website/docs/r/db_instance_automated_backups_replication.markdown b/website/docs/r/db_instance_automated_backups_replication.markdown index fe72467c56b8..61183de3f75f 100644 --- a/website/docs/r/db_instance_automated_backups_replication.markdown +++ b/website/docs/r/db_instance_automated_backups_replication.markdown @@ -94,7 +94,6 @@ configuration options: - `create` - (Default `75m`) How long to wait before RDS successfully starts replication of automated backups to a different AWS Region. - `update` - (Default `75m`) How long to wait before RDS completes updating existing replication of automated backups to a different AWS Region. -- `delete` - (Default `75m`) How long to wait before RDS stops automated backup replication for a DB instance. ## Import From 0d7e03f5a60e6979bf1e524eb5bd1dc59182d7aa Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Wed, 13 Jul 2022 11:14:23 +0200 Subject: [PATCH 6/8] Create 25796.txt --- .changelog/25796.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/25796.txt diff --git a/.changelog/25796.txt b/.changelog/25796.txt new file mode 100644 index 000000000000..5cd5349582db --- /dev/null +++ b/.changelog/25796.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_db_instance_automated_backups_replication: Add support for custom timeouts (create and delete) +``` From 6f266c452d4c9dc27ed22ea618879eaaa3189edc Mon Sep 17 00:00:00 2001 From: Bruno Schaatsbergen Date: Fri, 15 Jul 2022 11:21:48 +0200 Subject: [PATCH 7/8] remove `update` and use the `delete` in `Timeouts` section --- .../docs/r/db_instance_automated_backups_replication.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/db_instance_automated_backups_replication.markdown b/website/docs/r/db_instance_automated_backups_replication.markdown index 61183de3f75f..3c7b913b5273 100644 --- a/website/docs/r/db_instance_automated_backups_replication.markdown +++ b/website/docs/r/db_instance_automated_backups_replication.markdown @@ -93,7 +93,7 @@ In addition to all arguments above, the following attributes are exported: configuration options: - `create` - (Default `75m`) How long to wait before RDS successfully starts replication of automated backups to a different AWS Region. -- `update` - (Default `75m`) How long to wait before RDS completes updating existing replication of automated backups to a different AWS Region. +- `delete` - (Default `75m`) How long to wait before RDS stops automated backup replication for a DB instance. ## Import From 03d4e710b959efbe728867ba33624df00f1e4aff Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 15 Jul 2022 11:45:18 -0400 Subject: [PATCH 8/8] r/aws_db_instance_automated_backups_replication: Configured DB Subnet Group in acceptance test configurations: 'InvalidVPCNetworkStateFault: Cannot create the DB Instance because db subnet group has not been specified which is required for a private DBInstance creation'. --- ...ance_automated_backups_replication_test.go | 92 +++++++++++-------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/internal/service/rds/instance_automated_backups_replication_test.go b/internal/service/rds/instance_automated_backups_replication_test.go index 73e11092d987..735eee2b0441 100644 --- a/internal/service/rds/instance_automated_backups_replication_test.go +++ b/internal/service/rds/instance_automated_backups_replication_test.go @@ -119,32 +119,54 @@ func TestAccRDSInstanceAutomatedBackupsReplication_kmsEncrypted(t *testing.T) { }, }) } - -func testAccInstanceAutomatedBackupsReplicationConfig_basic(rName string) string { +func testAccInstanceAutomatedBackupsReplicationConfig_base(rName string, storageEncrypted bool) string { return acctest.ConfigCompose(acctest.ConfigMultipleRegionProvider(2), fmt.Sprintf(` -resource "aws_db_instance" "test" { - allocated_storage = 10 - identifier = %[1]q - engine = "postgres" - engine_version = "13.4" - instance_class = "db.t3.micro" - name = "mydb" - username = "masterusername" - password = "mustbeeightcharacters" - backup_retention_period = 7 - skip_final_snapshot = true +data "aws_availability_zones" "available" { + state = "available" + + filter { + name = "opt-in-status" + values = ["opt-in-not-required"] + } provider = "awsalternate" } -resource "aws_db_instance_automated_backups_replication" "test" { - source_db_instance_arn = aws_db_instance.test.arn +resource "aws_vpc" "test" { + cidr_block = "10.1.0.0/16" + + tags = { + Name = %[1]q + } + + provider = "awsalternate" } -`, rName)) + +resource "aws_subnet" "test" { + count = 2 + + cidr_block = "10.1.${count.index}.0/24" + availability_zone = data.aws_availability_zones.available.names[count.index] + vpc_id = aws_vpc.test.id + + tags = { + Name = %[1]q + } + + provider = "awsalternate" +} + +resource "aws_db_subnet_group" "test" { + name = %[1]q + subnet_ids = aws_subnet.test[*].id + + tags = { + Name = %[1]q + } + + provider = "awsalternate" } -func testAccInstanceAutomatedBackupsReplicationConfig_retentionPeriod(rName string) string { - return acctest.ConfigCompose(acctest.ConfigMultipleRegionProvider(2), fmt.Sprintf(` resource "aws_db_instance" "test" { allocated_storage = 10 identifier = %[1]q @@ -156,39 +178,37 @@ resource "aws_db_instance" "test" { password = "mustbeeightcharacters" backup_retention_period = 7 skip_final_snapshot = true + storage_encrypted = %[2]t + db_subnet_group_name = aws_db_subnet_group.test.name provider = "awsalternate" } +`, rName, storageEncrypted)) +} + +func testAccInstanceAutomatedBackupsReplicationConfig_basic(rName string) string { + return acctest.ConfigCompose(testAccInstanceAutomatedBackupsReplicationConfig_base(rName, false), ` +resource "aws_db_instance_automated_backups_replication" "test" { + source_db_instance_arn = aws_db_instance.test.arn +} +`) +} +func testAccInstanceAutomatedBackupsReplicationConfig_retentionPeriod(rName string) string { + return acctest.ConfigCompose(testAccInstanceAutomatedBackupsReplicationConfig_base(rName, false), ` resource "aws_db_instance_automated_backups_replication" "test" { source_db_instance_arn = aws_db_instance.test.arn retention_period = 14 } -`, rName)) +`) } func testAccInstanceAutomatedBackupsReplicationConfig_kmsEncrypted(rName string) string { - return acctest.ConfigCompose(acctest.ConfigMultipleRegionProvider(2), fmt.Sprintf(` + return acctest.ConfigCompose(testAccInstanceAutomatedBackupsReplicationConfig_base(rName, true), fmt.Sprintf(` resource "aws_kms_key" "test" { description = %[1]q } -resource "aws_db_instance" "test" { - allocated_storage = 10 - identifier = %[1]q - engine = "postgres" - engine_version = "13.4" - instance_class = "db.t3.micro" - name = "mydb" - username = "masterusername" - password = "mustbeeightcharacters" - backup_retention_period = 7 - storage_encrypted = true - skip_final_snapshot = true - - provider = "awsalternate" -} - resource "aws_db_instance_automated_backups_replication" "test" { source_db_instance_arn = aws_db_instance.test.arn kms_key_id = aws_kms_key.test.arn