t2 instance and t4g instance are not compatible and hence cannot be directly converted by just changing the instance type. Is there any way where the instance type t2 can be migrated to t4g instance without going through setting up again from scratch?
Any instances suffixed with
g are running on a Graviton chip, these run on an Arm architecture whereas your
t2 will be running on Intel (x86).
The base Amazon Machine Image (AMI) for a graviton based instance must be from an Arm architecture to allow these instance types to be launched, therefore there is not a quick way to migrate data.
From the system point of view you will need to ensure that the packages you are currently using are also available for Arm, if they are not you would need to look into alternatives. There might also be changes to your own software that are needed to make it compatiable.
Assuming you have not already, for the future it is worth looking into an orchestration tool to configure your instances so that it is quick to configure, such tools that exist are Ansible, Chef and Puppet.
For any files that exist on disk either use a shared NFS mount between the old and new instance (using the EFS service) or look at uploading to S3 and then copying down to your new instance once it has launched.