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/db_instance: Fix bug introduced v3.29.0, name, snapshot conflicts #17755

Merged
merged 2 commits into from
Feb 23, 2021

Conversation

anGie44
Copy link
Contributor

@anGie44 anGie44 commented Feb 22, 2021

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 #17712, closes #17722
Relates #17037, #17156

Output from acceptance testing:

--- PASS: TestAccAWSDBInstance_MySQL_SnapshotRestoreWithEngineVersion (1192.86s)

Notes

@ghost ghost added size/L Managed by automation to categorize the size of a PR. service/rds Issues and PRs that pertain to the rds service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 22, 2021
@anGie44 anGie44 force-pushed the b-db-instance-forcenew-conficts-snapshot-id branch 7 times, most recently from ce84d17 to d346dee Compare February 22, 2021 21:53
@anGie44 anGie44 marked this pull request as ready for review February 22, 2021 21:54
@anGie44 anGie44 requested a review from a team as a code owner February 22, 2021 21:54
@YakDriver YakDriver self-assigned this Feb 22, 2021
@anGie44 anGie44 force-pushed the b-db-instance-forcenew-conficts-snapshot-id branch from d346dee to 1bc2ac6 Compare February 22, 2021 22:44
@ghost ghost added size/M 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 Feb 22, 2021
@anGie44 anGie44 added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. labels Feb 22, 2021
@anGie44 anGie44 force-pushed the b-db-instance-forcenew-conficts-snapshot-id branch from 1bc2ac6 to 86c2c26 Compare February 22, 2021 22:56
@anGie44 anGie44 force-pushed the b-db-instance-forcenew-conficts-snapshot-id branch from 86c2c26 to 72f9407 Compare February 23, 2021 00:01
@ghost ghost added size/S 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 Feb 23, 2021
@YakDriver
Copy link
Member

YakDriver commented Feb 23, 2021

Here is a sum up of what we've learned going through this.

Original issue #17037 resulted in fix #17156. However, #17037 did not include any configuration detailing how the problem occurred and merely that a problem had occurred. Unfortunately, the speculative fix in #17156 could not have fixed the issue. The #17037 op was concerned about a diff (ForceNew) and all that the #17156 fix did was throw new errors. Throwing errors cannot resolve erroneous diffs.

#17156 resulted in many kinds of problems noted in #17712 and #17722. For example, the ConflictsWith addition instantly errored configs with empty snapshot_identifiers but name. Next, when restoring from an instance with a name to an instance without name but with snapshot_identifier, you'd receive an error on the second apply because of the computed name. For example, the config below should be valid but #17156 checks caused the error:

resource "aws_db_instance" "db" {
  allocated_storage    = 5
  engine               = "mysql"
  engine_version       = "5.7"
  instance_class       = "db.t3.micro"
  deletion_protection  = false
  skip_final_snapshot  = true
  snapshot_identifier  = aws_db_snapshot.test.db_snapshot_identifier
  tags = {
    "foo" = "bar"
  }
  identifier         = "yakdriver-tf-acc-target"
  maintenance_window = "Sun:00:00-Sun:08:00"
}

resource "aws_db_instance" "source" {
  allocated_storage    = 5
  engine               = "mysql"
  engine_version       = "5.7"
  identifier           = "yakdriver-tf-acc-source"
  instance_class       = "db.t3.micro"
  name                 = "yakdrivertfaccdbtesst"
  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 = "yakdriver-tf-acc-snap"
}

@YakDriver YakDriver added this to the v3.29.1 milestone Feb 23, 2021
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

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

Looking good! 🎉

This is reverting a previous change that didn't include new acceptances tests so I'm using a random set of acceptance tests to ensure nothing went awry. (Daily tests will ensure the rest work as well.)

GovCloud:

--- PASS: TestAccAWSDBInstance_MinorVersion (330.86s)
--- PASS: TestAccAWSDBInstance_namePrefix (362.36s)
--- PASS: TestAccAWSDBInstance_DeletionProtection (399.23s)
--- PASS: TestAccAWSDBInstance_basic (448.55s)
--- PASS: TestAccAWSDBInstance_kmsKey (452.26s)
--- PASS: TestAccAWSDBInstance_EnabledCloudwatchLogsExports_Postgresql (470.55s)
--- PASS: TestAccAWSDBInstance_Password (474.81s)
--- PASS: TestAccAWSDBInstance_iamAuth (498.87s)
--- PASS: TestAccAWSDBInstance_IsAlreadyBeingDeleted (525.67s)
--- PASS: TestAccAWSDBInstance_DbSubnetGroupName (531.73s)
--- PASS: TestAccAWSDBInstance_DbSubnetGroupName_VpcSecurityGroupIds (531.89s)

us-west-2:

--- PASS: TestAccAWSDBInstance_CACertificateIdentifier (330.23s)
--- PASS: TestAccAWSDBInstance_generatedName (382.24s)
--- PASS: TestAccAWSDBInstance_DbSubnetGroupName_VpcSecurityGroupIds (489.53s)
--- PASS: TestAccAWSDBInstance_MaxAllocatedStorage (505.53s)
--- PASS: TestAccAWSDBInstance_optionGroup (530.20s)
--- PASS: TestAccAWSDBInstance_cloudwatchLogsExportConfiguration (564.96s)
--- PASS: TestAccAWSDBInstance_portUpdate (645.56s)
--- PASS: TestAccAWSDBInstance_EnabledCloudwatchLogsExports_MSSQL (677.47s)
--- PASS: TestAccAWSDBInstance_MonitoringRoleArn_RemovedToEnabled (724.28s)
--- PASS: TestAccAWSDBInstance_NoDeleteAutomatedBackups (737.83s)
--- PASS: TestAccAWSDBInstance_FinalSnapshotIdentifier_SkipFinalSnapshot (789.48s)
--- PASS: TestAccAWSDBInstance_FinalSnapshotIdentifier (832.39s)
--- PASS: TestAccAWSDBInstance_EnabledCloudwatchLogsExports_Oracle (832.94s)

@anGie44 anGie44 merged commit 68f9c46 into main Feb 23, 2021
@anGie44 anGie44 deleted the b-db-instance-forcenew-conficts-snapshot-id branch February 23, 2021 01:13
@github-actions github-actions bot modified the milestones: v3.29.1, v3.30.0 Feb 23, 2021
@anGie44 anGie44 modified the milestones: v3.30.0, v3.29.1 Feb 23, 2021
github-actions bot pushed a commit that referenced this pull request Feb 23, 2021
@YakDriver YakDriver changed the title r/db_instance: update plan-time validation for snapshot_identifier/name/username r/db_instance: Fix bug introduced v3.29.0, name, snapshot conflicts Feb 23, 2021
@ghost
Copy link

ghost commented Feb 23, 2021

This has been released in version 3.29.1 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 for triage. Thanks!

@ghost
Copy link

ghost commented Mar 25, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/rds Issues and PRs that pertain to the rds service. size/S 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
2 participants