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

resource aws_db_parameter_group has continuous drift since AWS provider 3.55.0 #20660

Closed
r-kok opened this issue Aug 23, 2021 · 12 comments
Closed
Assignees
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.

Comments

@r-kok
Copy link

r-kok commented Aug 23, 2021

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 other comments that do not add relevant new information or questions, 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 CLI and Terraform AWS Provider Version

Terraform v0.14.11
AWS provider 3.55.0

Affected Resource(s)

  • aws_db_parameter_group

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp

Debug Output

Panic Output

Expected Behavior

since we had no drift using provider version 3.54, we expected no drift with version 3.55 either.

Actual Behavior

A terraform plan using AWS provider 3.55 generates the output shown below.
When we terraform apply these changes, and run terraform plan a second time, we get the same output again.
Thus the changes were not applied as expected.

  # module.pcs.module.oracle.aws_db_parameter_group.oracle will be updated in-place
  ~ resource "aws_db_parameter_group" "oracle" {
        id          = "kt-pcs-oracle"
        name        = "kt-pcs-oracle"
        tags        = {
            "Environment" = "kt"
        }
        # (4 unchanged attributes hidden)

      + parameter {
          + apply_method = "immediate"
          + name         = "open_cursors"
          + value        = "300"
        }
      - parameter {
          - apply_method = "pending-reboot" -> null
          - name         = "open_cursors" -> null
          - value        = "300" -> null
        }
        # (27 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Steps to Reproduce

  1. terraform plan : shows terraform drift
  2. terraform apply -auto-approve: apply seems succesful.
  3. terraform plan : shows same terraform drift as if the apply failed (UNEXPECTED)

Important Factoids

We use the parameter group in the context of an Oracle RDS database.

As a workaround we have temporarily pinned the version of the AWS provider in a versions.tf file:

terraform {
  required_version = ">= 0.14"
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = "3.54.0"
    }
  }

References

We suspect it is related to or caused by this item in the AWS provider changelog:

  • #0000
@github-actions github-actions bot added needs-triage Waiting for first response or review from a maintainer. service/rds Issues and PRs that pertain to the rds service. labels Aug 23, 2021
@YakDriver YakDriver self-assigned this Aug 23, 2021
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 23, 2021
@sshishov
Copy link

@r-kok , you have a typo in the title. The version indicated in the title should be 3.55.0. Please correct.

@r-kok r-kok changed the title resource aws_db_parameter_group has continuous drift since AWS provider 3.0.55 resource aws_db_parameter_group has continuous drift since AWS provider 3.55.0 Sep 15, 2021
@antdking
Copy link

Confirming I get this on the latest versions:

$ terraform version
Terraform v1.0.7
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v3.59.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

@r-kok
Copy link
Author

r-kok commented Nov 14, 2021

Today I had some time to reproduce the issue.
The following terraform file shows a regression since provider 3.55.0:

resource "aws_db_parameter_group" "attempt4" {
  name = "attempt4"
  family = "oracle-ee-12.1"

  parameter {
    apply_method = "immediate"
    name         = "open_cursors"
    value        = "300"
  }
}

Steps to reproduce

  1. Plan and apply the above code using AWS provider version 3.54.0.
  2. Run terraform plan once more. Note that terraform reports there are no changes.
  3. Upgrade to AWS provider version 3.55.0 (or higher).
  4. Run terraform plan. Note this time there are changes (!). See below for the diff reported by terraform.
  5. Run terraform apply. Hopefully this resolves that changes
  6. Run terraform plan. Alas, the changes are still there.
  7. Downgrade to AWS provider version 3.54.0
  8. Run terraform plan. There are no changes.
  # aws_db_parameter_group.attempt4 will be updated in-place
  ~ resource "aws_db_parameter_group" "attempt4" {
        id          = "attempt4"
        name        = "attempt4"
        tags        = {}
        # (4 unchanged attributes hidden)

      + parameter {
          + apply_method = "immediate"
          + name         = "open_cursors"
          + value        = "300"
        }
      - parameter {
          - apply_method = "pending-reboot" -> null
          - name         = "open_cursors" -> null
          - value        = "300" -> null
        }
    }

Plan: 0 to add, 1 to change, 0 to destroy.

@r-kok
Copy link
Author

r-kok commented Feb 16, 2022

I learned some more about the circumstances under which this error occurs.

The problem arises when you try to create a "user" parameter with a value that is identical to value on "system" or "engine-default" source level. For example, oracle parameter "open_cursors" has value 300 on "system" source level.

If you try to set "open_cursors" = 300 you have drift.
In the AWS console you can see that the parameter that gets created is a parameter with source level "system".
This is unexpected.

If instead you set "open_cursors" = 301 there is no drift.
In the AWS console you see that the parameter that gets created has source level "user", as expected.

Tested with terraform AWS provider 4.0.0

@r-kok
Copy link
Author

r-kok commented Feb 16, 2022

The bad resource has drift, the ok resource does not.

resource "aws_db_parameter_group" "bad" {
  name = "bad"
  family = "oracle-ee-12.1"

  parameter {
    apply_method = "immediate"
    name         = "open_cursors"
    value        = "300"
  }
}

resource "aws_db_parameter_group" "ok" {
  name = "ok"
  family = "oracle-ee-12.1"

  parameter {
    apply_method = "immediate"
    name         = "open_cursors"
    value        = "301"
  }
}

@gclough
Copy link

gclough commented Feb 21, 2022

@r-kok, we have noticed the same thing, in that when a parameter value matches the AWS default setting we get constant drift. On PostgreSQL RDS we changed our minimum max_wal_size formula to 2112 to ensure it never matches the default of 2048. Now we no longer get drift on every terraform run:

"max_wal_size" = [min(max(lookup(lookup(local.instance_parameter_map, local.instance_class), "db_instance_class_memory_gib") * 128, 2112), 65536), "immediate"]       # Max WAL before forced checkpoint RAM/10485760, min 2112MiB, max 64GiB (default: 2GiB) # WARNING: Do not set to 2048, or it triggers a terraform provider bug

@leslie-alldridge
Copy link
Contributor

pls fix :)

@blowfishpro
Copy link

Is this the same issue as #22028 ?

@gclough
Copy link

gclough commented Apr 6, 2022

Is this the same issue as #22028 ?

@blowfishpro , it appears so, yes. As discussed above, the trigger seems to be when a parameter is supplied which also matches the default setting in AWS. I would suggest that #22028 is closed as a dupe of this.

@james-valente-simplisafe
Copy link
Contributor

I believe this issue can be closed now.

See the merged PR #24737 for a demonstration of why this is a behavioral artifact of the AWS API and not Terraform itself. The PR adds a NOTE to the latest aws_db_parameter_group resource documentation, explaining why this is happening.

@justinretzolk
Copy link
Member

Hey y'all 👋 Based on the details @jvalente11 included in their PR -- which added some information around this to the resource documentation -- this looks to be an upstream issue with AWS. Since the behavior is now documented, we'll close this issue for now, but I'll also be following up with a support ticket to AWS to report the unexpected behavior.

@github-actions
Copy link

github-actions bot commented Sep 9, 2022

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 have found a problem that seems similar to this, 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 Sep 9, 2022
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.
Projects
None yet
Development

No branches or pull requests

10 participants