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_rds_reserved_instance must be replaced #37530

Open
ericrichtert opened this issue May 15, 2024 · 1 comment
Open

[Bug]: aws_rds_reserved_instance must be replaced #37530

ericrichtert opened this issue May 15, 2024 · 1 comment
Labels
bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. service/rds Issues and PRs that pertain to the rds service.

Comments

@ericrichtert
Copy link
Contributor

ericrichtert commented May 15, 2024

Terraform Core Version

1.8.2

AWS Provider Version

5.49.0

Affected Resource(s)

  • data aws_rds_reserved_instance_offering
  • resource aws_rds_reserved_instance
  • resource aws_db_instance

When we do a little change on the aws_db_instance (for example bump the version of posgres from 15.6 to 15.7), the aws_rds_reserved_instance_offering is renewed, and that causes everything to fail

Expected Behavior

No change to the data aws_rds_reserved_instance_offering and the resource aws_rds_reserved_instance

Actual Behavior

data aws_rds_reserved_instance_offering will be renewed, so the offering_id is not known, what causes the resource aws_rds_reserved_instance to be replaced. And that's not possible, the resource is deleted from the state, but can not be recreated as the reserved instance already exists in AWS.

Relevant Error/Panic Output Snippet

Terraform will perform the following actions:
  # data.aws_rds_reserved_instance_offering.tf-rds-reserved-instance-offering will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_rds_reserved_instance_offering" "tf-rds-reserved-instance-offering" {
      + currency_code       = (known after apply)
      + db_instance_class   = "db.m6i.large"
      + duration            = 31536000
      + fixed_price         = (known after apply)
      + id                  = (known after apply)
      + multi_az            = true
      + offering_id         = (known after apply)
      + offering_type       = "All Upfront"
      + product_description = "postgresql"
    }
  # aws_db_instance.tf-postgres-xxx-xxxx will be updated in-place
  ~ resource "aws_db_instance" "tf-postgres-xxx-xxxx" {
      ~ engine_version                        = "15.6" -> "15.7"
        id                                    = "db-xxxxxx"
        # (70 unchanged attributes hidden)
    }

  # aws_rds_reserved_instance.tf-rds-reserved-instance must be replaced
-/+ resource "aws_rds_reserved_instance" "tf-rds-reserved-instance" {
      ~ arn                 = "arn:aws:rds:eu-west-1:xxx:ri:tf-postgres-xxx-xxxx" -> (known after apply)
      ~ currency_code       = "USD" -> (known after apply)
      ~ db_instance_class   = "db.m6i.large" -> (known after apply)
      ~ duration            = 31536000 -> (known after apply)
      ~ fixed_price         = 2266 -> (known after apply)
      ~ id                  = "tf-postgres-xxx-xxxx" -> (known after apply)
      ~ lease_id            = "9b82a584-xxxx-xxxx-bd09-ca12442090e2" -> (known after apply)
      ~ multi_az            = true -> (known after apply)
      ~ offering_id         = "a249c8ac-xxxx-xxxx-9045-bae473a0b703" # forces replacement -> (known after apply) # forces replacement
      ~ offering_type       = "All Upfront" -> (known after apply)
      ~ product_description = "postgresql" -> (known after apply)
      ~ recurring_charges   = [
          - {
              - recurring_charge_amount    = 0
              - recurring_charge_frequency = "Hourly"
            },
        ] -> (known after apply)
      ~ start_time          = "2023-06-20T11:07:03Z" -> (known after apply)
      ~ state               = "active" -> (known after apply)
      - tags                = {} -> null
      ~ usage_price         = 0 -> (known after apply)
        # (3 unchanged attributes hidden)
    }

Terraform Configuration Files

resource "aws_db_instance" "tf-postgres-xxx-xxxx" {
  identifier              = "tf-postgres-xxx-xxxx"
  allocated_storage       = "40"
  max_allocated_storage   = "1000"
  storage_type            = "gp3"
  instance_class          = "db.m6i.large"
  engine                  = "postgres"
  engine_version          = "15.7"
  #removed the rest
}

data "aws_rds_reserved_instance_offering" "tf-rds-reserved-instance-offering" {
  db_instance_class   = aws_db_instance.tf-postgres-xxx-xxxx.instance_class
  duration            = 31536000 #this is 1 year
  multi_az            = aws_db_instance.tf-postgres-xxx-xxxx.multi_az
  offering_type       = "All Upfront"
  product_description = "postgresql"
}

resource "aws_rds_reserved_instance" "tf-rds-reserved-instance" {
  offering_id    = data.aws_rds_reserved_instance_offering.tf-rds-reserved-instance-offering.offering_id
  reservation_id = lower(aws_db_instance.tf-postgres-xxx-xxxx.identifier)
  instance_count = 1
}

Steps to Reproduce

Make little change on the aws_db_instance (we updated the version from 15.6 to 15.7) and do an apply

Debug Output

Not sure if this is a bug or "works as designed", if you need some debug logging, I can create it.

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

No

@ericrichtert ericrichtert added the bug Addresses a defect in current functionality. label May 15, 2024
@github-actions github-actions bot added the service/rds Issues and PRs that pertain to the rds service. label May 15, 2024
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. service/rds Issues and PRs that pertain to the rds service.
Projects
None yet
Development

No branches or pull requests

1 participant