title: How to iterate over multiple subnets in Route Table Associations with AWS CDK?
body: <p>I have a list of subnets that I would want to iterate into my public and private route table. Here is an example of my function for my public RT:</p>
  <pre><code>// This will grab the public RT and associate all public subnets to the RT.
  props.pubSubnetId.forEach((public_subnets) =&gt; {
    const publicRTAssoc = new ec2.CfnSubnetRouteTableAssociation(this, &quot;publicRTAssoc&quot;, {
      routeTableId: props.pubRouteTableId,
      subnetId: public_subnets
    });
  });
  </code></pre>
  <p>I see nothing wrong with my code but when I run <code>cdk synth</code>, I get this error:</p>
  <p><code>Error: There is already a Construct with name 'publicRTAssoc' in CloudformationArchStack [CloudformationArchStack]</code></p>
  <p>I believe the iteration is interfering with the <code>id</code> in my function. Would appreciate any help in solving this problem.</p>