hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.62k stars 9.01k forks source link

RDS: aws_db_instance not assigning custom parameter_group_name #31719

Closed hitesh-dev19 closed 4 months ago

hitesh-dev19 commented 1 year ago

Terraform Core Version

Terraform v1.4.0 on darwin_arm64

AWS Provider Version

4.67.0

Affected Resource(s)

aws_db_instance

Expected Behavior

Trying to create Cross Region Replica for Oracle RDS Instance

Actual Behavior

I am trying to create the cross region replica for Oracle RDS Instance providing custom parameter_group_name, but still it is getting assigned to default parameter group, eventually it is failing with the error , Error: waiting for RDS DB Instance (******) create: unexpected state 'incompatible-parameters', wanted target 'available, storage-optimization'. , and when I try to reapply terraform changes, it is showing that the changes for parameter group with the custom one, then it is deleting that instance and creating new instance again with the same default parameter group.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_db_instance" "test-replica" {
   identifier             = "mytestinstance"
   replicate_source_db    = "arn:aws:rds:us-east-1:****"
   instance_class         = "db.m5.xlarge"
   apply_immediately      = true
   publicly_accessible    = false
   skip_final_snapshot    = true
   vpc_security_group_ids = [data.aws_security_group.static.id]
   parameter_group_name   = "custom-parameter-group"
   storage_encrypted = true
   iam_database_authentication_enabled = true
   iops = 1000
   tags = {
    Application = "test -replica"
   }
}

Steps to Reproduce

terraform plan

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 year ago

Hey @hitesh-dev19 👋 Thank you for taking the time to raise this! I did a bit of looking around, and I believe this may be a configuration issue rather than a bug within the provider. I'll link the most relevant documents that I found below.

hitesh-dev19 commented 1 year ago

Hi justinretzolk, Thanks for the reply, my point is though I am giving the custom parameter group the new replica is still getting attached to default parameter group.

justinretzolk commented 1 year ago

Hey @hitesh-dev19 -- I see where you're coming from now. So that we have the relevant information in order to be able to look into this, can you supply debug logs (redacted as needed) as well?

hitesh-dev19 commented 1 year ago

Hey @justinretzolk , I can refer my issue, which is very similar to https://github.com/hashicorp/terraform-provider-aws/issues/218 but there a subsequent terraform apply changes parameter_group_name to the correct value and do an RDS reboot to get their changes. But for me subsequent terraform plan this diff is evident with the correct parameter group, but when I apply it, it is destroying the replica which was created before and recreating new one with the same default parameter group and not applying custom parameter group.

hitesh-dev19 commented 1 year ago

Hey @justinretzolk , I have noticed one more thing that the resource is getting tainted that is the reason it is getting destroyed and recreate all the time with the same default parameter group. So I have untainted the resource and reapply the same so then the parameter_group_name got updated but it required manual reboot to get that applied.

So now its happening in the same way like https://github.com/hashicorp/terraform-provider-aws/issues/218 , but that issue has been resolved in the past but that doesn't look that way.

Can you please confirm this. thanks.

hitesh-dev19 commented 1 year ago

Hello @justinretzolk ,

I have noticed that with the latest terraform aws provider version update v5.0.0, the oracle replica resource is still failing with the same error Error: waiting for RDS DB Instance (******) create: unexpected state 'incompatible-parameters', wanted target 'available, storage-optimization'. But with this latest update the created resource is not there in the terraform state . In earlier versions the resource is in taint state at-least which helped to create resource by rebooting manually . This time it is not the case. I need to import the resource again to match the state. Could you please help me with my case or let me know If I am missing anything. Thanks.

hitesh-dev19 commented 1 year ago

Any help appreciated !

skeesara02 commented 9 months ago

We are also having the same issue with RDS oracle, unable to pass custom parameter group, though we are passing, its taking default parameter group and then the status is going to **incompatible-parameters** as we have updated a parameter in custom parameter group - max_string_size from STANDARD to EXTENDED. But this feature is working from from AWS CLI

koolbaar commented 8 months ago

Is there any update on this bug. This still seems to be happening. Creating a cross region read replica for RDS-Oracle does not respect the Custom parameter group that we pass. If we try to modify the read replica, to fix the same, it tries to delete and re-create. In-region Read-Replica does not have any issues.

kutttinoti commented 7 months ago

Facing same problem. Curious to know if this is even acknowledged as a bug from hashicorp.

Interestingly, while the tfl state shows as tainted and we can see that it is associating the default parameter group in AWS console, Tfl state output shows the custom parameter group name. So, custom parameter group is not completely ignored.

Also, aws cli command create-db-instance-read-replica succeeds with exact same parameter group. Hoping to get a resolution sooner on this.

hitesh-dev19 commented 7 months ago

@justinretzolk can you please look at this bug, its still unresolved.

gdavison commented 7 months ago

Hi @hitesh-dev19, can you please share more of your Terraform configuration? Specifically, where you create the parameter group. It would also be helpful to see the configuration that creates the source database and its parameter group.

rampalanofficial commented 4 months ago

Hi @gdavison

Attaching two tar files that can be used for reproducing this problem, where parameter group that is passed to aws_db_instance is not used when creating the readreplica instance, especially when extended parameters are used (eg: max_string_size)

hashi-module-rds-oracle.tar.gz => This will create rds-oracle terraform module that can be used to create a RDS Oracle db instance with parameter/option groups. call_rds_oracle.tar.gz => This will use rds-oracle terraform module twice, one for creating the primary instance and another for creating read replica instance.

hashi-module-rds-oracle.tar.gz

call_rds_oracle.tar.gz

github-actions[bot] commented 4 months ago

This functionality has been released in v5.40.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[bot] commented 3 months ago

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.