Trying to upgrade AWS provider to version 4, but getting the following error in RDS module:
Error: Conflicting configuration arguments
│
│ with module.my-instance-mysql-eu[0].module.rds.module.db_instance.aws_db_instance.this[0],
│ on .terraform/modules/my-instance-mysql-eu.rds/modules/db_instance/main.tf line 47, in resource "aws_db_instance" "this":
│ 47: db_name = var.db_name
│
│ "db_name": conflicts with replicate_source_db
2
Answers
The error is stating that the
db_name
attribute conflicts with thereplicate_source_db
attribute; you cannot specify both attributes, it must be one or the other. This is also mentioned in the Terraform documentation.If you are replicating an existing RDS database, the database name will be the same as the name of the source. If this is a new database, do not set the
replicate_source_db
attribute at all.I encountered a similar issue with the
engine
&engine_version
variables:I found a good example of a solution here: https://github.com/terraform-aws-modules/terraform-aws-rds/blob/v5.2.2/modules/db_instance/main.tf
And I managed to solve this with the below conditions:
If
var.replicate_source_db
is not null, then the username/password/engine/engine_version will be set to null (which is what we need as these variables cannot be specified for a replica). And if it is not a replica, then we will have the variables set accordingly 🙂You can add the same for the
db_name
parameter: