I already have a VPC and a subnet in it...my EC2 provisioning .tf file throws error

terraform apply throws this message

Error: Error launching source instance: MissingInput: No subnets found for the default VPC ‘vpc-bdfd5adb’. Please specify a subnet.
status code: 400, request id: 535462ba-b5d9-4517-a980-357cb07a941a

      # Terraform Settings Block
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      #version = "~> 3.21" # Optional but recommended in production
    }
  }
}

# Provider Block
provider "aws" {
  profile = "default" # AWS Credentials Profile configured on your local desktop terminal  $HOME/.aws/credentials
  region="us-west-1"
}


# Resource Block
resource "aws_instance" "ec2demo" {
  ami           = "ami-055fb0e8f77b0b6bd" # Amazon Linux in us-east-1, update as per your region
  instance_type = "t2.micro"

}

First, Please check if the AMI is present in the default region
As given above Amazon Linux AMI mentioned is in us-east-1 and region is us-west-1.

Can you put your VPC and Subnet tf here as well ?

add below resource in resource block from aws :

subnet_id = “subnet-xxxxxx”

should resolve your issue

Thanks it resolved.

resource "aws_instance" "test_server" {
  ami           = "ami-xxxxxxxxc"
  instance_type = "t2.micro"
  subnet_id = "subnet-xxxxxxx"
}