1
votes

Trying to upgrade Aurora version to latest one. Before upgrading terraform plan is working fine. Once I did upgrading I'm getting:

Error: Unsupported attribute

on main.tf line 50, in locals: 50:

      "master_username" = module.db.this_rds_cluster_master_username
       module.db is a object, known only after apply

This object does not have an attribute named "this_rds_cluster_master_username".

I tried replacing module.db with variables var.this_rds_cluster_master_username and it worked, but I want to make changes in output file not with variables. Any assistance would really appreciated.

output.tf

            output "this_rds_cluster_master_username" {
                   value       = module.db.this_rds_cluster_master_username
                    description = "The master username."
                }

main.tf

         locals {
           rds_cluster_master_creds = {
          "master_username" = module.db.this_rds_cluster_master_username
          "master_password" = module.db.this_rds_cluster_master_password
                }
             }

How to modify output module?

#module db

module "db" {
  source  = "terraform-aws-modules/rds/aws"
  version = "5.2.0"
  engine            = "aurora-postgressql"
  engine_mode       = "serveless"
  engine_version    = null
  db_subnet_group_name = aws_db_subnet_group.rds_isolated.name
  vpc_id              = local.vpc_id
  deletion_protection = true
      }

#locals

 locals {
       rds_cluster_master_creds = {
      "master_username" = module.db.this_rds_cluster_master_username
      "master_password" = module.db.this_rds_cluster_master_password
            }
         }
1
Can you shown complete code demonstrating what is module.db and how do you use it? - Marcin
module "db" { source = "terraform-aws-modules/rds/aws" version = "5.2.0" engine = "aurora-postgressql" engine_mode = "serveless" engine_version = null db_subnet_group_name = aws_db_subnet_group.rds_isolated.name vpc_id = local.vpc_id deletion_protection = true - Coffee_addict
Can you please edit the question with correcly formated code blocks. - Marcin
I've edited the question.I've aurora cluster db module and locals in main.tf. With old version of aurora it is working fine when I update with latest one 5.2.0 I'm getting issues.I dont know exact reason of issue but it may be related with output value. Do I need to update the output value? - Coffee_addict

1 Answers

2
votes

Module terraform-aws-modules/rds/aws does not have output called this_rds_cluster_master_username. Instead it is called db_master_password. So instead of the following:

module.db.this_rds_cluster_master_username

you should be using

module.db.db_instance_username

Same for this_rds_cluster_master_password.