Traffic between subnets in the same VPC can be routed using route tables. By default, AWS creates a main route table for your VPC, but you can create custom route tables and associate them with specific subnets.
Example code snippet to create a custom route table:
aws ec2 create-route-table --vpc-id <vpc-id>
Example code snippet to associate a route table with a subnet:
aws ec2 associate-route-table --subnet-id <subnet-id> --route-table-id <route-table-id>