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

Bug: aws_db_option_group: cannot update tags #7114

Closed
sjauld opened this issue Jan 10, 2019 · 4 comments · Fixed by #7125
Closed

Bug: aws_db_option_group: cannot update tags #7114

sjauld opened this issue Jan 10, 2019 · 4 comments · Fixed by #7125
Labels
bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service.
Milestone

Comments

@sjauld
Copy link
Contributor

sjauld commented Jan 10, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.11.11
+ provider.aws v1.55.0

Affected Resource(s)

  • aws_db_option_group

Terraform Configuration Files

provider "aws" {
  region  = "ap-southeast-2"
  version = "~> 1.55"
}

resource "aws_iam_role" "rds_backup" {
  name = "DemoRDSServiceRoleForBackup"

  assume_role_policy = <<EOF
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": "sts:AssumeRole",
      "Principal": {
        "Service": "rds.amazonaws.com"
      },
      "Effect": "Allow",
      "Sid": ""
    }
  ]
}
EOF
}

resource aws_db_option_group "buggy" {
  name                     = "buggy-option-group"
  option_group_description = "A terraform example"
  engine_name              = "sqlserver-web"
  major_engine_version     = "14.00"

  option {
    option_name = "SQLSERVER_BACKUP_RESTORE"

    option_settings {
      name  = "IAM_ROLE_ARN"
      value = "${aws_iam_role.rds_backup.arn}"
    }
  }

  tags {
    colour = "green"
  }
}

Debug Output

https://gist.github.com/sjauld/21e2fbae17aab4b21c65f38fc68d402b

Panic Output

Expected Behavior

Should have been able to change the tag from "green" to "blue" and it would have successfully updated.

Actual Behavior

Error: Error applying plan:

1 error(s) occurred:

* aws_db_option_group.buggy: 1 error(s) occurred:

* aws_db_option_group.buggy: Error modifying DB Option Group: InvalidParameterValue: At least one option must be added, modified, or removed.
        status code: 400, request id: 70ca9ca3-0e02-4482-92a9-fd4f657a1cbc

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.

Steps to Reproduce

  1. terraform apply
  2. change the tag from green to blue
  3. terraform apply

Important Factoids

References

  • #0000
@sjauld sjauld changed the title aws_db_option_group: cannot update tags Bug: aws_db_option_group: cannot update tags Jan 10, 2019
@bflad bflad added bug Addresses a defect in current functionality. service/rds Issues and PRs that pertain to the rds service. labels Jan 11, 2019
@bflad
Copy link
Contributor

bflad commented Jan 12, 2019

Pull request submitted: #7125

bflad added a commit that referenced this issue Jan 12, 2019
…ate and skip ModifyOptionGroup when no option updates

References:
* #209
* #1167
* #1876
* #6365
* #7114

Previously, this Terraform resource was not able to perform any drift detection on or import the state of the `option` attribute. The caveat is that while RDS returns only modified options, it will return all option settings whether modified or not from their default values. To workaround this option settings issue, we pass in the options from the Terraform configuration and ignore default values that are not present in the configuration.

This also fixes an issue on update where `ModifyOptionGroup` was being called without any actual option updates, which would generate an error and prevent other updates from occurring. While the update logic was correctly using `d.HasChange()` before, when working with complex `TypeSet` attributes like `option` it can apparently be fooled. We use similar length check logic in the `aws_db_parameter_group` resource for example.

Output from acceptance testing (AWS Standard):

```
--- PASS: TestAccAWSDBOptionGroup_timeoutBlock (13.50s)
--- PASS: TestAccAWSDBOptionGroup_generatedName (13.50s)
--- PASS: TestAccAWSDBOptionGroup_namePrefix (13.58s)
--- PASS: TestAccAWSDBOptionGroup_basic (13.67s)
--- PASS: TestAccAWSDBOptionGroup_multipleOptions (14.08s)
--- PASS: TestAccAWSDBOptionGroup_sqlServerOptionsUpdate (23.90s)
--- PASS: TestAccAWSDBOptionGroup_Option_OptionSettings (27.86s)
--- PASS: TestAccAWSDBOptionGroup_Option_OptionSettings_MultipleNonDefault (29.37s)
--- PASS: TestAccAWSDBOptionGroup_OracleOptionsUpdate (32.14s)
--- PASS: TestAccAWSDBOptionGroup_Option_OptionSettings_IAMRole (32.40s)
--- PASS: TestAccAWSDBOptionGroup_Tags (38.88s)
--- PASS: TestAccAWSDBOptionGroup_Tags_WithOptions (43.07s)
--- PASS: TestAccAWSDBOptionGroup_basicDestroyWithInstance (499.04s)
```

Output from acceptance testing (AWS GovCloud (US), failures will be separately addressed with other GovCloud fixes):

```
--- FAIL: TestAccAWSDBOptionGroup_OracleOptionsUpdate (12.33s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
        	* aws_db_option_group.bar: 1 error occurred:
        	* aws_db_option_group.bar: Error modifying DB Option Group: InvalidParameterValue: Version 12.1.0.4.v1 is invalid for OEM_AGENT option. Valid versions are 13.2.0.0.v1,13.2.0.0.v2
        	status code: 400, request id: 748c6b88-9406-436b-b755-461feb20abbf

--- PASS: TestAccAWSDBOptionGroup_namePrefix (14.68s)
--- PASS: TestAccAWSDBOptionGroup_basic (14.73s)
--- PASS: TestAccAWSDBOptionGroup_generatedName (14.80s)
--- PASS: TestAccAWSDBOptionGroup_timeoutBlock (14.82s)
--- PASS: TestAccAWSDBOptionGroup_multipleOptions (15.53s)
--- FAIL: TestAccAWSDBOptionGroup_Option_OptionSettings_IAMRole (19.14s)
    testing.go:538: Step 0 error: Check failed: Check 4/4 error: Expected option setting to be a valid IAM role but received arn:aws-us-gov:iam::--OMITTED--:role/rds-backup-option-group-test-terraform-0w89k
--- PASS: TestAccAWSDBOptionGroup_sqlServerOptionsUpdate (25.33s)
--- PASS: TestAccAWSDBOptionGroup_Option_OptionSettings_MultipleNonDefault (26.42s)
--- PASS: TestAccAWSDBOptionGroup_Option_OptionSettings (28.46s)
--- PASS: TestAccAWSDBOptionGroup_Tags (35.49s)
--- PASS: TestAccAWSDBOptionGroup_Tags_WithOptions (39.27s)
--- PASS: TestAccAWSDBOptionGroup_basicDestroyWithInstance (498.37s)
```
@bflad bflad added this to the v1.56.0 milestone Jan 14, 2019
@bflad
Copy link
Contributor

bflad commented Jan 14, 2019

The fix for this has been merged and will release with version 1.56.0 of the Terraform AWS provider, likely middle of this week. 👍

@bflad
Copy link
Contributor

bflad commented Jan 16, 2019

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

@ghost
Copy link

ghost commented Apr 1, 2020

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 and limited conversation to collaborators Apr 1, 2020
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. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
2 participants