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

New resource: aws_db_instance_automated_backups_replication #23759

Merged

Conversation

bschaatsbergen
Copy link
Member

@bschaatsbergen bschaatsbergen commented Mar 18, 2022

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #23673.
Closes #16708.
Similar #20448.

Output from acceptance testing:

$ make testacc TESTS=TestAccRDSInstanceAutomatedBackupReplication_ PKG=rds                                                                             (base) 
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 20 -run='TestAccRDSInstanceAutomatedBackupReplication_'  -timeout 180m
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_basic
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_basic
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_basic
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod (1112.49s)
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_basic (1143.40s)
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted (1166.08s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/rds        1166.316s

@bschaatsbergen bschaatsbergen marked this pull request as draft March 18, 2022 23:10
@github-actions github-actions bot added provider Pertains to the provider itself, rather than any interaction with AWS. service/rds Issues and PRs that pertain to the rds service. needs-triage Waiting for first response or review from a maintainer. size/M Managed by automation to categorize the size of a PR. labels Mar 18, 2022
@github-actions github-actions bot added size/L Managed by automation to categorize the size of a PR. and removed size/M Managed by automation to categorize the size of a PR. labels Mar 18, 2022
…ion' is set through either env var or provider. And give a default value for `retention_period`
@bschaatsbergen
Copy link
Member Author

bschaatsbergen commented Mar 21, 2022

@ewbankkit wanted to get some of your input here, the API is a bit poorly designed in my opinion. It's expected that this call is done from within the destination region (if you want to replicate backups from us-east-1 to us-west-2, I would have to declare the resource in us-west-2, pointing to a source_db_instance_arn in us-east-1).

This conflicts a little bit with having to wait for the instance becoming 'available' after modifying..

At the moment I have this, which works fine but I still don't find it pretty that it has to be declared in the destination region.

resource "aws_db_instance_backup_replication" "default" {
  source_db_instance_arn = "arn:aws:rds:us-east-1:832224938332:db:database-1"
  kms_key_id             = "arn:aws:kms:us-west-2:832224938332:key/example-key-id"
}

provider "aws" {
  region = "us-west-2"
}

@YakDriver
Copy link
Member

YakDriver commented Mar 21, 2022

@bschaatsbergen We've run into this sort of thing in a few places. A recent one that I worked on is here:

useConn := conn // clusters may not all be in the same region
if clusterRegion != meta.(*conns.AWSClient).Region {
useConn = rds.New(meta.(*conns.AWSClient).Session, aws.NewConfig().WithRegion(clusterRegion))
}
if err := waitForClusterUpdate(useConn, dbi, timeout); err != nil {
return fmt.Errorf("failed to update engine_version, waiting for RDS Global Cluster (%s) to update: %s", dbi, err)
}

If it needs to wait on something in another region, my opinion is that it should wait the same, as though it were in the same region.

@bschaatsbergen
Copy link
Member Author

@bschaatsbergen We've run into this sort of thing in a few places. A recent one that I worked on is here:

useConn := conn // clusters may not all be in the same region
if clusterRegion != meta.(*conns.AWSClient).Region {
useConn = rds.New(meta.(*conns.AWSClient).Session, aws.NewConfig().WithRegion(clusterRegion))
}
if err := waitForClusterUpdate(useConn, dbi, timeout); err != nil {
return fmt.Errorf("failed to update engine_version, waiting for RDS Global Cluster (%s) to update: %s", dbi, err)
}

If it needs to wait on something in another region, my opinion is that it should wait the same, as though it were in the same region.

Thank you Yak! :)

@github-actions github-actions bot added size/XL Managed by automation to categorize the size of a PR. and removed size/L Managed by automation to categorize the size of a PR. labels Mar 22, 2022
@github-actions github-actions bot added the tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. label Mar 22, 2022
@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Mar 24, 2022
@bschaatsbergen bschaatsbergen marked this pull request as ready for review March 24, 2022 20:34
@justinretzolk justinretzolk added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Mar 24, 2022
…tedBackupByID' -> 'FindDBInstanceAutomatedBackupByARN'.
…waiting for deletion.

Acceptance test output:

% make testacc TESTS=TestAccRDSInstanceAutomatedBackupReplication_basic PKG=rds
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 20 -run='TestAccRDSInstanceAutomatedBackupReplication_basic'  -timeout 180m
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_basic
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_basic
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_basic
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_basic (1340.32s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	1345.529s
@ewbankkit ewbankkit modified the milestone: Roadmap Mar 29, 2022
@bschaatsbergen
Copy link
Member Author

bschaatsbergen commented Mar 29, 2022

Had a rough weekend, looks like I missed a few things yesterday. Thanks for the extra pair of eyes @ewbankkit .

@ewbankkit
Copy link
Contributor

ewbankkit commented Mar 29, 2022

@bschaatsbergen In general everything was great.
The only significant change was to the wait after the call to StopDBInstanceAutomatedBackupsReplication. The long list of DB Instance statuses seemed quite brittle so I went with the approach of polling the DB Instance's list of DBInstanceAutomatedBackupsReplications until the required backup ARN is no longer present.

Do you know anything about the PreSignedUrl parameter? The User Guide says

If you encrypt the backups, you must also include a presigned URL.

but the TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted test case is currently passing without it.

I see no harm in adding pre_signed_url as an optional argument (I'll do that).

ewbankkit
ewbankkit previously approved these changes Mar 29, 2022
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTS=TestAccRDSInstanceAutomatedBackupReplication_ PKG=rds ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 2 -run='TestAccRDSInstanceAutomatedBackupReplication_'  -timeout 180m
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_basic
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_basic
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod
=== RUN   TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted
=== PAUSE TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_basic
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_basic (1439.87s)
=== CONT  TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_kmsEncrypted (1479.54s)
--- PASS: TestAccRDSInstanceAutomatedBackupReplication_retentionPeriod (1405.06s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	2854.272s

@bschaatsbergen
Copy link
Member Author

bschaatsbergen commented Mar 29, 2022

@ewbankkit Clear, regarding the PreSignedUrl parameter, I read the following when digging through the SDK

PreSignedUrl
// Specifying SourceRegion autogenerates a pre-signed URL that
// is a valid request for the operation that can be executed in the source
// Amazon Web Services Region.

/ SourceRegion is the source region where the resource exists. This is not
// sent over the wire and is only used for presigning. This value should always
// have the same region as the source ARN.
SourceRegion *string type:"string" ignore:"true"

At first I was under the impression that this was handled internally if not specified. After taking a look at Event History in CloudTrail I didn't see any PreSignedUrl (explicitly setting it through the CLI it does show in the event) going over the wire even if the automated backup was encrypted.

If we want to avoid adding PreSignedUrl to the scheme, we can maybe set the SourceRegion in the StartDBInstanceAutomatedBackupsReplicationInput, otherwise lets add it 👍

@ewbankkit ewbankkit changed the title New resource: aws_db_instance_backup_replication New resource: aws_db_instance_backups_replication Mar 29, 2022
@ewbankkit
Copy link
Contributor

OK, another change 😄. Renamed the resource to aws_db_instance_automated_backups_replication to match the underlying AWS API.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTS=TestAccRDSInstanceAutomatedBackupsReplication_ PKG=rds ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 2 -run='TestAccRDSInstanceAutomatedBackupsReplication_'  -timeout 180m
=== RUN   TestAccRDSInstanceAutomatedBackupsReplication_basic
=== PAUSE TestAccRDSInstanceAutomatedBackupsReplication_basic
=== RUN   TestAccRDSInstanceAutomatedBackupsReplication_retentionPeriod
=== PAUSE TestAccRDSInstanceAutomatedBackupsReplication_retentionPeriod
=== RUN   TestAccRDSInstanceAutomatedBackupsReplication_kmsEncrypted
=== PAUSE TestAccRDSInstanceAutomatedBackupsReplication_kmsEncrypted
=== CONT  TestAccRDSInstanceAutomatedBackupsReplication_basic
=== CONT  TestAccRDSInstanceAutomatedBackupsReplication_kmsEncrypted
--- PASS: TestAccRDSInstanceAutomatedBackupsReplication_basic (1188.64s)
=== CONT  TestAccRDSInstanceAutomatedBackupsReplication_retentionPeriod
--- PASS: TestAccRDSInstanceAutomatedBackupsReplication_kmsEncrypted (1249.54s)
--- PASS: TestAccRDSInstanceAutomatedBackupsReplication_retentionPeriod (1047.58s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/rds	2240.134s

@ewbankkit ewbankkit changed the title New resource: aws_db_instance_backups_replication New resource: aws_db_instance_automated_backups_replication Mar 29, 2022
@ewbankkit ewbankkit merged commit 303b347 into hashicorp:main Mar 29, 2022
@ewbankkit ewbankkit changed the title New resource: aws_db_instance_automated_backups_replication New resource: aws_db_instance_automated_backups_replication Mar 29, 2022
@github-actions github-actions bot added this to the v4.9.0 milestone Mar 29, 2022
@bschaatsbergen bschaatsbergen deleted the r/db_instance_backup_replication branch March 29, 2022 22:24
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

This functionality has been released in v4.9.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented May 8, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. provider Pertains to the provider itself, rather than any interaction with AWS. service/rds Issues and PRs that pertain to the rds service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
5 participants