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,
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?
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, "construct");
new HitCounterStack(cdk.App, "stack");
please correct me if I made any mistake in code. Thanks in advance :)