I created 2 VPCs using aws-cdk. cdk is creating route tables dynamically when cloudformation stack is created. I created a peering connection between the two VPCs I created using
CfnVPCPeeringConnection but I am not sure how to add route to vpc peering connection as I do not know what would be the RouteTableId.
You probably mean the peering connection id. Once you know it you can modify the routing tables.
In typescript, you get it this way
import ec2 = require("@aws-cdk/aws-ec2");
const vpc_peering = new ec2.CfnVPCPeeringConnection (...)
const vpc_peering_id = vpc_peering.ref