title: The difference between a Stack and Construct in AWS CDK
body: <p>I'm new to CDK and confused about the difference between a Construct and a Stack. With CDK, we can define reusable cloud components known as Construct, and we can further compose these together into a Stack or Apps. See the diagram from AWS website below,</p>
  <p><a href="https://i.stack.imgur.com/kgE0H.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kgE0H.png" alt="enter image description here" /></a></p>
  <p>However, I've seen class where a construct is created by extending the Construct base class, and also class where a Stack is created by extending the Stack base class. Both child classes can be used later to create the main stack. For example, see the code below, I can create a Construct or a Stack called HitCounter class that creates the same set of resources and use them the same way in the main Stack. So what's the difference between using a Stack or a Construct?</p>
  <pre><code>import * as cdk from '@aws-cdk/core';
  
  export class HitCounterConstruct extends cdk.Construct {} // imagine this construct creates a bunch of related resources
  
  export class HitCounterStack extends cdk.Stack {} // imagine this stack creates the same resources as the construct class above
  
  // In main stack file App.ts
  
  new HitCounterConstruct(cdk.App, &quot;construct&quot;);
  new HitCounterStack(cdk.App, &quot;stack&quot;);
  </code></pre>
  <p>please correct me if I made any mistake in code. Thanks in advance :)</p>