title: What is the correct way to pass an RDS DatabaseCluster from one stack to another?
body: <p>I have a db Stack that is then passed to another Stack:</p>
  
  <pre class="lang-js prettyprint-override"><code>class DbStack extends cdk.Stack {
    public dbSocket: string;
    public dbReadSocket: string;
    constructor(scope: cdk.Construct, id: string, props: { vpc: ec2.Vpc }) {
      super(scope, id);
      const { vpc } = props;
      const db = new DatabaseCluster(this, "Database", {
        engine: rds.DatabaseClusterEngine.AuroraPostgresql,
        ....
      });
      this.dbSocket = db.clusterEndpoint.socketAddress;
      this.dbReadSocket = db.clusterReadEndpoint.socketAddress;
    }
  }
  
  const dbStack = new DbStack(app, "db", { vpc });
  
  new MyStack(app, "mystack", {
    vpc,
    dbSocket: dbStack.dbSocket,
    dbReadSocket: dbStack.dbReadSocket,
  }
  </code></pre>
  
  <p>In the other stack, I pass those sockets to ECS environment variables:</p>
  
  <pre class="lang-js prettyprint-override"><code>export class PpfStack extends cdk.Stack {
    constructor(scope: cdk.Construct, id: string, props: MyStackProps) {
      super(scope, id, props);
  
      const { vpc, dbSocket, dbReadSocket } = props;
  
      new MyService(this, "svc", {
        vpc,
        ...
        environment: {
          NODE_ENV: "production",
          DATABASE_RO_SOCKET: dbReadSocket,
          DATABASE_RW_SOCKET: dbSocket,
        },
      });
  </code></pre>
  
  <p>Unfortunately the environment variables end up coming out as:</p>
  
  <pre><code>db-databasec2aad89b-1t1yxzplxjsvu.cluster-cppalohfw5gz.us-east-2.rds.amazonaws.com:{IndirectPort}
  </code></pre>
  
  <p><strong>UPDATE</strong> This looks like a bug: <a href="https://github.com/awslabs/aws-cdk/issues/2711" rel="nofollow noreferrer">https://github.com/awslabs/aws-cdk/issues/2711</a></p>