title: Terraform: How to pass output from one resource to another?
body: <p>I'm using Aurora serverless Mysql and ECS and trying to use secrets generated by aws secret manager in a file named rds.tf and want to use it another resource in a file called ecs.tf</p>
  <pre><code>resource &quot;random_password&quot; &quot;db_instance_aurora_password&quot; {
    length  = 40
    special = false
    keepers = {
      database_id = aws_secretsmanager_secret.db_instance_aurora_master_password.id
    }
  </code></pre>
  <p>Above is rds.tf, which works and generates a random password. In my second file ecs.tf, I want to use the</p>
  <pre><code>resource &quot;aws_ecs_task_definition&quot; &quot;task&quot; {
    family = var.service_name
    container_definitions = templatefile(&quot;${path.module}/templates/task_definition.tpl&quot;, {
      DB_USERNAME  = var.db_username
      DB_PASSWORD  = random_password.db_instance_aurora_password.result
    })
  }
  </code></pre>
  <p>How to export, the output of the db_password and use it in another resource(ecs.tf)?</p>
  <pre><code>output &quot;aurora_rds_cluster.master_password&quot; {
    description = &quot;The master password&quot;
     value    =  random_password.db_instance_aurora_password.result }
  </code></pre>