skip to Main Content

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


  1. The error is stating that the db_name attribute conflicts with the replicate_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.

    Login or Signup to reply.
  2. I encountered a similar issue with the engine & engine_version variables:

    │ Error: Conflicting configuration arguments
    │ 
    │   with module.production.module.replica_app_db_production.aws_db_instance.db,
    │   on modules/rds/postgres/main.tf line 36, in resource "aws_db_instance" "db":
    │   36:   engine                      = var.engine
    │ 
    │ "engine": conflicts with replicate_source_db
    ╵
    ╷
    │ Error: Conflicting configuration arguments
    │ 
    │   with module.production.module.replica_app_db_production.aws_db_instance.db,
    │   on modules/rds/postgres/main.tf line 37, in resource "aws_db_instance" "db":
    │   37:   engine_version              = var.engine_version
    │ 
    │ "engine_version": conflicts with replicate_source_db
    ╵
    

    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:

      # Replicas will use source metadata
      username       = var.replicate_source_db != null ? null : var.username
      password       = var.replicate_source_db != null ? null : var.password
      engine         = var.replicate_source_db != null ? null : var.engine
      engine_version = var.replicate_source_db != null ? null : var.engine_version
    

    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:

    db_name       = var.replicate_source_db != null ? null : var.db_name
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search