Unable to deploy all resources together

Hello Everyone,

I am exploring python cdktf and having separate files for every resource. As a best practice, I have imported classes in main.py. When I trigger the ‘cdktf deploy’ the result is “Error: Usage Error: Found more than one stack, please specify a target stack. Run cdktf deploy with one of these stacks: pp, s3-stack, AWSProviderStack, ec2-stack”.

Below, I am attaching my source codes.

#my_s3.py
from constructs import Construct
from cdktf import TerraformStack
from cdktf_cdktf_provider_aws.s3_bucket import S3Bucket
from my_provider import AWSProviderStack

class MyS3BucketStack(TerraformStack):
def init(self, scope:Construct, ns: str):
super().init(scope, ns)

    AWSProviderStack(self, 'AWSProviderStack')

    s3_bucket = S3Bucket(self, 'my_s3_bucket',
                         bucket='pikludevsecps',  # Replace with your bucket name
                         acl='private',
                         tags={
                           "Name": "Dev"  
                         }
                    )  

#my_ec2.py
from constructs import Construct
from cdktf import TerraformStack
from my_provider import AWSProviderStack
from cdktf_cdktf_provider_aws.instance import Instance

class Ec2Stack(TerraformStack):

def __init__(self, scope: Construct, id: str, **kwargs):
    super().__init__(scope, id, **kwargs)


    AWSProviderStack(self, 'AWSProviderStack')

    new_ec2_instance = Instance(self, "my-instance", 
                            instance_type="t2.micro",
                            tags={
                                "Name": "Dev"
                            }    
                        )

#my_provider.py
from constructs import Construct
from cdktf import TerraformStack
from cdktf_cdktf_provider_aws.provider import AwsProvider

class AWSProviderStack(TerraformStack):
def init(self, scope:Construct, ns: str, **kwargs):
super().init(scope, ns)

    # Define AWS provider
    self.provider = AwsProvider(self, "aws", region="ap-south-1")

#main.py
from constructs import Construct
from cdktf import App, TerraformStack
from my_s3 import MyS3BucketStack
from my_ec2 import Ec2Stack

class MyStack(TerraformStack):
def init(self, scope:Construct, ns: str):
super().init(scope, ns)

  s3_stack = MyS3BucketStack(self, 's3-stack')
  ec2_stack = Ec2Stack(self, 'ec2-stack')

app = App()
MyStack(app,“pp”)
app.synth()

You can specify multiple stacks by name (I think wildcards also work) when running the deploy command (check out the help for the exact syntax).

You may be better off extending Construct for the areas that you are currently using TerraformStack for. Stacks are more typically used to represent different environments, regions, or layers in your application. They can be modified independently (sometimes there are dependencies) and store their state separately.
Constructs are just a mechanism for grouping resources logically within the resource tree that makes up a stack.